我的问题是我的mongoose Schema中有一个静态方法,就像这样
0
在chatMessageSchema的一个静态方法
中ready: function(){
this.currentPage = 0;
}
现在我想做的是
在创建期间,我想在const chatMessageSchema = new Schema({
id: String,
something: String,
.
.
posted_by_user: String,
}, { collection: 'XXXX' });
上执行加入,或者我必须在下一个chatMessageSchema.statics.createATextPostInChatRoom = function (roomid,
message) {
return this.create({
roomid: roomid,
message: message,
type: MESSAGE_TYPES.TYPE_TEXT,
notes: {},
posted_by_user: 'XXXXXXX',
read_by_recipients: posted_by_user
})
.then(post => post)
.catch(error => {
throw(error)
});
}
块中加入
任何帮助都会非常感激。
答案 0 :(得分:0)
我是使用我在$lookup
中使用的MongoDB aggregation
方法完成的。