您好,登錄后才能下訂單哦!
config/plugin.js
mongoose: {
enable: true,
package: 'egg-mongoose'
}
config/config.default.js
config.mongoose = {
client: {
url: 'mongodb://devuser:devuser123@127.0.0.1:27017/db_co_assist',
options: {}
}
};
app/model/test.js
'use strict';
module.exports = app => {
const mongoose = app.mongoose;
const Schema = mongoose.Schema;
const TestSchema = new Schema({
name: {
type: String,
},
age: {
type: Number,
},
__v: {
type: Number
}
});
return mongoose.model('Test', TestSchema, 'test');
};
更新文檔
let conditions = {
_id: '5d4287eb6884ad1c30cc97b1'
};
let update = {
name: '測試8888888888888',
age: 100,
__v: 100102
};
this.ctx.model.Test.update(conditions, update, function (err) {
if (err) {
console.error(err);
}
});
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。