Closed dodgertodd closed 7 years ago
exports is a convenience object that simply references module.exports. I used exports.[modelName] for clarity.
exports.[modelName] = foo var foo = require(./path/to/file.js).modelName
Is the same as
module.exports = foo var foo = require(./path/to/file.js)
The first is slightly more verbose but a lot more clear IMO. That pattern also allows you to export and name multiple objects or functions. In that case we could also do:
module.exports = { modelName: model someFunction: function(){} }
I just think the exports.modelName pattern is more clear.
I'm pretty sure this is functionally equivalent. @kingbrendann please checkout and run it for me, however you've been testing it? Also please see how I call
module.exports
to export feedItemController, whereas you were usingexports.[modelName]
. I don't know which is right. I thought maybe you had a mongoose reason for doing it that way.