Thursday 8 June 2017

What does module.exports = { Mongoose , models: { ... } } mean?

I am learning Node/Mongo, and now I can understand the code like this,

module.exports = mongoose.model('User', UserSchema);

I have trouble understanding the following,

module.exports = { Mongoose, // var Mongoose = require('mongoose');
    models: {
        user: require('./schemas/user.js'),
        room: require('./schemas/room.js')
    }
};

I can see the author wants to export Mongoose and the models. But is the exported object a JSON object? Is the Mongoose in it a key or a value? Is JSON allowed a key without value or a value without a key? Or I am getting all wrong?



via Qiulang

No comments:

Post a Comment