List 如何查询MongoDB中项目位于文档数组中的匹配文档

List 如何查询MongoDB中项目位于文档数组中的匹配文档,list,mongodb,List,Mongodb,如果我存储的文档如下所示: doc = { 'Things' : [ 'one' , 'two' , 'three' ] } 如何查询在内容中包含一个的文档 我知道$in操作符根据列表查询文档项,但这是一种相反的情况。任何帮助都会很棒。使用MongoDB的支持: MongoDB提供了一个有趣的“多键”功能,可以自动索引对象值的数组。 [……] db.articles.find( { tags: 'april' } ) {"name" : "Warm Weather" , "au

如果我存储的文档如下所示:

doc = {
    'Things' : [ 'one' , 'two' , 'three' ]
    }
如何查询在<代码>内容<代码>中包含一个<代码>的文档

我知道
$in
操作符根据列表查询文档项,但这是一种相反的情况。任何帮助都会很棒。

使用MongoDB的支持:

MongoDB提供了一个有趣的“多键”功能,可以自动索引对象值的数组。
[……]

db.articles.find( { tags: 'april' } )
{"name" : "Warm Weather" , "author" : "Steve" , 
 "tags" : ["weather","hot","record","april"] , 
 "_id"  : "497ce4051ca9ca6d3efca323"}
基本上,您不必担心
事物的数组性,MongoDB将为您解决这一问题;在MongoDB shell中,类似这样的东西可以工作:

db.your_collection.find({ Things: 'one' })