Mongodb Mongoose:在数组中查询来自另一个数组的值
我有一个类似的模式:Mongodb Mongoose:在数组中查询来自另一个数组的值,mongodb,mongoose,Mongodb,Mongoose,我有一个类似的模式: const Combined = new Schema({ done: [{ type: Schema.Types.ObjectId, ref: 'orders' }], notDone: [{ type: Schema.Types.ObjectId, ref: 'orders' }], extraInfo: { type: {} } }, { timestamps: true }); 当我要处理所有有订单的订单时。\u id在d
const Combined = new Schema({
done: [{ type: Schema.Types.ObjectId, ref: 'orders' }],
notDone: [{ type: Schema.Types.ObjectId, ref: 'orders' }],
extraInfo: { type: {} }
}, {
timestamps: true
});
当我要处理所有有订单的订单时
。\u id
在done
或notDone
中,我要:
const query = {
$or: [
{ done: { $all: [order._id] } },
{ notDone: { $all: [order._id] } }
],
$populate: ['done', 'notDone']
}
现在我有一个订单列表
如何将所有组合起来
,其中完成
或未完成
包含来自订单的id
中的任何