【发布时间】:2020-03-26 16:49:47
【问题描述】:
exp我的收藏用户
[
{
_id: ObjectId('123456')
username: 'test'
},
{
_id: ObjectId('654321')
username: 'test2'
},
{
_id: ObjectId('789101')
username: 'test3'
}
]
我的数组可用:
var usersId = [ObjectId('123456'), ObjectId('654321')]
我想使用字段用户名查找并且仅在数组 usersId 中可用
我的测试不工作:
db.users.find({
username: keyword,
_id: { $in: usersId }
})
【问题讨论】:
-
哇,非常感谢@zishe
标签: javascript node.js mongodb mongoose