【发布时间】:2018-09-05 07:15:27
【问题描述】:
我的收藏中有两个文档
{ participants: [ '5ab8fcf6d8bfca2cc0aebb37', '5ab8fd15d8bfca2cc0aebb38' ],
_id: 5ab9a5a0cb274a2064b65d1b,
__v: 0
},
{ participants: [ '5ab8fcf6d8bfca2cc0aebb37', '5ab8fcf6d8bfca2cc0aebb37' ],
_id: 5ab9a5a7cb274a2064b65d1c,
__v: 0
}
我有很多人喜欢
persons = [ 5ab8fcf6d8bfca2cc0aebb37, '5ab8fcf6d8bfca2cc0aebb37' ]
现在我正在尝试使用此查询查找包含类似于数组persons 的participants 字段的文档。
Participant.find({participants: {$all: persons}}).exec()
.then(connected => {
console.log(connected);
// perform some stuff
});
它把我两个文件都作为输出。 不知道是什么问题。
提前感谢。
【问题讨论】:
标签: javascript node.js mongodb mongodb-query