for example
aModel = {
user_id: String,
file_name: String,
page_id: Number
}
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]
}
It is known that user_id, file_name, page_id and model are asynchronous. How to search these two models at the same time?
Go to the next step after getting two results
The code is as follows. In fact, I feel that the writing is not elegant at all...
If you need them to execute concurrently, you can use Promise
If you don’t need to do it concurrently and can do it synchronously, you can use
yield
orasync/await
Of course the upstairs is not very elegant. What you need is async/await, so upgrade node to 7.6 or above
Really? Doesn't the mongoose api have a method for multi-table query?