egg-mongoose
Egg's mongoose plugin.
Install
$ npm i egg-mongoose --save
Usage
exports.mongoose = {
enable: true,
package: 'egg-mongoose',
};
Configuration
exports.mongoose = {
url: 'mongodb://127.0.0.1/example',
options: {}
};
see config/config.default.js for more detail.
Multi-mongos support
exports.mongoose = {
url: 'mongodb://mongosA:27501,mongosB:27501',
options: {}
};
Example
module.exports = app => {
const mongoose = app.mongoose;
const UserSchema = new mongoose.Schema({
userName: { type: String },
password: { type: String }
});
return mongoose.model('User', UserSchema);
}
exports.index = function* (ctx) {
ctx.body = yield ctx.model.User.find({});
}
Questions & Suggestions
Please open an issue here.
Contribution
If you are a contributor, follow CONTRIBUTING.
License
MIT