【发布时间】:2018-12-28 20:05:12
【问题描述】:
我有订单和用户,我想通过 Mongoose Populate 或其他方式通过用户电话号码查找订单我该怎么做?
订单(_id,item,user_id) 用户(_id、电子邮件、电话)
const orders = await Order.find({}).populate({path: 'user', select: 'phone'})
我想要这样的东西,我无法弄清楚 (user.phone='xxxxxx')。
谢谢
【问题讨论】:
-
看看在集合上使用 $lookup 而不是尝试过滤填充,如下所示:stackoverflow.com/questions/11303294/…
标签: mongodb mongoose mongodb-query mongoose-populate