Egg's mongoose plugin.
$ npm i egg-mongoose --save # (just use npm link)
// {app_root}/config/plugin.js
exports.mongoose = {
enable: true,
package: 'egg-mongoose',
};
// {app_root}/config/config.default.js
exports.mongoose = {
url: 'mongodb://127.0.0.1/example',
options: {}
};
see config/config.default.js for more detail.
// app/model/user.js
module.exports = mongoose => {
const UserSchema = new mongoose.Schema({
userName: { type: String },
password: { type: String }
});
return mongoose.model('User', UserSchema);
}
// app/controller/user.js
exports.index = function* () {
this.body = yield this.model.user.find({});
}
Please open an issue here.