元素数组中字符串上的CouchDB查询选择器

元素数组中字符串上的CouchDB查询选择器,couchdb,Couchdb,我需要获取游戏数组列表中存在的射箭文档。如何使用CouchDB选择器 [{ "name": "John", "games": ["Archery", "Board sports"] }, { "name": "Sara", "games": ["Fishing", "Archery"] }, { "name": "Tara", "games": ["Decathlon"] }] 您可以使用$elemMatch: { "selector":

我需要获取
游戏
数组列表中存在的
射箭
文档。如何使用CouchDB选择器

[{
    "name": "John",
    "games": ["Archery", "Board sports"]
},
{
    "name": "Sara",
    "games": ["Fishing", "Archery"]
},
{
    "name": "Tara",
    "games": ["Decathlon"]
}]

您可以使用
$elemMatch

{
   "selector": {
      "games": {
         "$elemMatch": {
            "$eq": "Archery"
         }
      }
   }
}
它将返回
游戏
场等于“射箭”的所有对象

可能重复的