How do MongoDB nested queries return all data?


clipboard.png
id!

this is my current practice. The problem is that the last res.send () only deals with the first traversal. If you put res.send () outside the traversal, the value of goodsList does not change. Is there a big answer?

Mar.08,2021

db.Classify.aggregation([{
    $lookup:{
       from: "Good",
       localField: "_id",
       foreignField: "classify_id",
       as: "goodsList"
    }
}])

nested queries
mongo support aggregation


later discovered that async.mapSeries can aggregate the results of multiple tasks

Menu