Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/12.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
Arrays 嵌套数组子文档的Restheart查询_Arrays_Mongodb_Subdocument_Restheart - Fatal编程技术网

Arrays 嵌套数组子文档的Restheart查询

Arrays 嵌套数组子文档的Restheart查询,arrays,mongodb,subdocument,restheart,Arrays,Mongodb,Subdocument,Restheart,我与mongodb和restheart合作 在我的nosql db中,我有一个具有以下结构的唯一文档: { "_id": "docID", "users": [ { "userID": "12", "elements": [ { "elementID": "1492446877599",

我与mongodb和restheart合作

在我的nosql db中,我有一个具有以下结构的唯一文档:

{
"_id": "docID",
"users": [
            {
             "userID": "12",                 
             "elements": [
                         {
                          "elementID": "1492446877599",
                          "events": [
                                     {
                                      "event1": "one"
                                     },   
                                     {                                       
                                      "event2": "two",
                                      }
                                     ]
                           }
               },
              {
             "userID": "11",                 
             "elements": [
                         {
                          "elementID": "14924",
                          "events": [
                                     {
                                      "event1": "one"
                                     },   
                                     {                                       
                                      "event2": "two",
                                      }
                                     ]
                           }
               }  

              ]  
}
如何构建url查询以获取id为11的用户

使用mongo shell,它应该是这样的:

db.getCollection('collection').find({},{'users':{'$elemMatch':{'userID':'12'}}}).pretty()
我在restheart上找不到类似的东西

有人能帮我吗

用这个

http://myHost:port/documents/docID?filter={%27users%27:{%27$elemMatch%27:{%27userID%27:%2712%27}}}

restheart返回所有文档:userID 11和12。

您的请求是针对文档资源的,即URL是
http://myHost:port/documents/docID

过滤器查询参数适用于收集请求,即
http://myHost:port/documents

在任何情况下,都需要使用投影(keys查询参数)来限制返回的属性

您应该使用以下请求(我还没有尝试过)来实现它:


http://myHost:port/documents?keys={“users”:{“$elemMatch”:{“userID”:“12”}}