Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Usergrid how do I get related entities nested in a single json and not only the link to them

When I query /mycollections?ql=Select * where name='dfsdfsdfsdfsdfsdf' I get

{
  "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
}

Now if I query /mycollections/2ff8961a-dea8-11e4-996b-63ce373ace35/relations I get the second entity

{
  "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"
}

What I want is that instead of providing me the path of the related entity Usergrid directly nest it in the first JSON answer so that I only need to make a single http request instead of two.

like image 704
Jan Moritz Avatar asked Apr 09 '15 14:04

Jan Moritz


1 Answers

You cannot. Usergrid is not designed in that way. You need to write an extra wrapper rest endpoint to simulate one response.

like image 141
Fatih S. Avatar answered Sep 27 '22 18:09

Fatih S.