CNode

mongoose 怎么多个model查询

问答
BBusyHe发布于9 年前最后回复9 年前3 回复4322 浏览0 收藏

不如有个A model: aModel = { user_id: String, file_name: String, page_id: Number } B model: fileSchema = new Schema({ page_id: Number, key: String, doc: String, title: String, sym: String });

bModel = { user_id: String, file_name: String, origin_file: String, new_file: [fileSchema] }

已知user_id,file_name,page_id, model find是异步的,怎么同时查找这两个model,得到两个结果后再进行下一步

查看回复

回复 (3)

X
xiaqiubo#1·9 年前

mongoose不是默认支持promise么?使用promise.all处理两个后拿到数据再处理后边的

B
babto#2·9 年前

promise ==> async / await

J
JarvisQJ#3·9 年前

function(){ function(){

}

}

参与回复
登录后即可参与回复。登录