我已经从 mongodb 集合生成动态报告。我从一个集合和例如客户端获取数据,并在数组中获取所有客户端 ID 例如["5b7869dff0be71721f53d2e3","5b7869dff0be71721f53d2e4","5b7869dff0be71721f53d2e3"]
当我使用数组从其他集合获取数据时,例如{"clientId": { $in: inArray } }
它给我空结果。因为如果我将{ "clientId": { $in: [ObjectId('5b785f243cc6c746af635dc8')] } } "ObjectId" word before the id. My Question is how i Put this ObjectId
工作放在数组中,则在数组中工作。
您可以使用 map 将数组映射到 ObjectId 数组
inArray = inArray.map( value => ObjectId(value) );
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句