使用Usergrid如何获得嵌套在单个json中的相关实体,而不仅仅是它们的链接

Jan*_*itz 7 apigee usergrid

当我查询/mycollections?ql=Select * where name='dfsdfsdfsdfsdfsdf'我得到

{
  "action" : "get",
  "application" : "859e6180-de8a-11e4-9360-f1aabbc15f58",
  "params" : {
    "ql" : [ "Select * where name='dfsdfsdfsdfsdfsdf'" ]
  },
  "path" : "/mycollections",
  "uri" : "http://localhost:8080/myorg/myapp/mycollections",
  "entities" : [ {
    "uuid" : "2ff8961a-dea8-11e4-996b-63ce373ace35",
    "type" : "mycollection",
    "name" : "dfsdfsdfsdfsdfsdf",
    "created" : 1428577466865,
    "modified" : 1428577466865,
    "metadata" : {
      "path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35",
      "connections" : {
        "relations" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations"
      }
    }
  } ],
  "timestamp" : 1428589309204,
  "duration" : 53,
  "organization" : "myorg",
  "applicationName" : "myapp",
  "count" : 1
}
Run Code Online (Sandbox Code Playgroud)

现在如果我查询/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations我得到第二个实体

{
  "action" : "get",
  "application" : "859e6180-de8a-11e4-9360-f1aabbc15f58",
  "params" : { },
  "path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations",
  "uri" : "http://localhost:8080/myorg/myapp/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations",
  "entities" : [ {
    "uuid" : "56a1185a-dec1-11e4-9ac0-e9343f86b604",
    "type" : "secondcollection",
    "name" : "coucou",
    "created" : 1428588269141,
    "modified" : 1428588269141,
    "metadata" : {
      "connecting" : {
        "relations" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations/56a1185a-dec1-11e4-9ac0-e9343f86b604/connecting/relations"
      },
      "path" : "/mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations/56a1185a-dec1-11e4-9ac0-e9343f86b604"
    }
  } ],
  "timestamp" : 1428589668542,
  "duration" : 51,
  "organization" : "myorg",
  "applicationName" : "myapp"
}
Run Code Online (Sandbox Code Playgroud)

我想要的是,不是向我提供相关实体的路径,而是将Usergrid直接嵌套在第一个JSON答案中,这样我只需要生成一个http请求而不是两个.

Cha*_*dru 0

不确定您使用的是什么数据库。如果您使用像 mongo 这样的文档数据库,那么您可以编写一个 Node.js 脚本来执行此操作。Apigee 有 volvo.js 检查是否可以执行脚本。