【发布时间】:2013-08-22 19:40:17
【问题描述】:
鉴于 MongoDB 中条目的以下结构:
{
_id: blahblah,
string_list: ['hello','large','world']
}
有没有办法执行如下搜索:
db.test.find({string_list:['large','world','hello']})
这将返回在string_list 字段中具有'hello'、'large' 和'world' 的任何文档(但没有其他字符串,只有这三个)以任何顺序?
我知道{$all:...} 'operator' 会做类似的事情,但据我所知,如果我使用过:
db.collection.find({string_list: {$all:['large','world','hello']}})
它还会返回以下条目:
{
_id: blahblah,
string_list: ['hello','large','world','two']
}
我不想要的。
【问题讨论】:
标签: arrays mongodb search database