我的代码:
const result = await db.collection('hospitals').aggregate([
{
$lookup: {
from: "nurses",localField: "nurses",foreignField: "_id",as: "result"
}
},{ $merge: "patients" }
]).toArray();
console.log(result);
将数据保存在mongodb数据库中的患者集合中,但在变量“结果”中得到一个空数组作为响应。
如何在不再次查询数据库的情况下获取数据?