Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Bash mongoDB correct find()命令_Bash_Mongodb_Search_Find - Fatal编程技术网

Bash mongoDB correct find()命令

Bash mongoDB correct find()命令,bash,mongodb,search,find,Bash,Mongodb,Search,Find,我有一个集合,其中的对象看起来像: { "_id":ObjectId(""), "payload":{ "roles":[ { "contract_part":"1111", "role_key":"", "party_key":"29-29", "address_key":null, "changed_at":"2017-07-18T18:30:00", "changed_nr

我有一个集合,其中的对象看起来像:

{
  "_id":ObjectId(""),
  "payload":{
  "roles":[
     {
        "contract_part":"1111",
        "role_key":"",
        "party_key":"29-29",
        "address_key":null,
        "changed_at":"2017-07-18T18:30:00",
        "changed_nr":NumberLong(1),
        "type":NumberLong(33),
        "contract_key":"999",
        "business_to":"2999-01-01T00:00:00",
        "business_from":"2017-07-18T18:30:00"
     }
  ]
},
   "id":NumberLong("10345"),
   "event":"role.created",
   "aggregate":"role",
   "timestamp":"2017-07-18T21:30:00.000+03:00"
}
我正在努力创建一个
db.collection.find()
,它将允许我使用特定的
“role\u key”
查找对象

db.collection.find({"payload.roles": {$elemMatch: {role_key:" "}}})

向我们展示您已经尝试过的,我们将很乐意帮助您。