如何在同一查询中使用SomeTable.create并一起执行连接

时间:2017-06-16 10:53:35

标签: javascript node.js mongodb mongoose-schema

我的问题是我的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) }); } 块中加入

任何帮助都会非常感激。

1 个答案:

答案 0 :(得分:0)

我是使用我在$lookup中使用的MongoDB aggregation方法完成的。

相关问题