对于mongo中给定的文档
{"_id" : "joe":
grocerylist: [ "cheddar", "apple", "oranges" ]
}
{"_id" : "joanna":
grocerylist: [ "cheddar", "foobar" ]
}
{"_id" : "john":
grocerylist: [ "apple", "oranges" ]
}
如果我搜索列表中有切达干酪的用户
find({"grocerylist" : cheddar}, fields={'_id' : 1})
我明白了
[{u'_id': u'joe'}, {u'_id': u'joanna'}]
使用Mongo,我怎么能得到一个匹配用户的列表,像这样。。你知道吗
[u'joe', u'joanna']
谢谢。你知道吗
一种选择是使用列表:
_id
在整个集合中是唯一的,因此您可以在这里使用^{相关问题 更多 >
编程相关推荐