lonelymo
lonelymo

Reputation: 4192

How do we store relationships in usergrid?

I have two collections 1)Cities 2) CarShowrooms. Now when I search for a car showroom let's say "Suzuki", I want to list all possible cities that has Suzuki show room.

On the other hand I want to list all CarShowrooms in a city.

Since it is a no-sql db, the only way to do this is to store cinema info at the CarShowroom and CarShowroom info on cinema. Is this correct?

Upvotes: 0

Views: 189

Answers (1)

Scott Ganyo
Scott Ganyo

Reputation: 311

Usergrid has a very flexible relationship structure that you can use as documented here.

In your example, you could create a one-way relationship (using entity names, but you could use UUIDs instead) like this:

curl -X POST https://api.usergrid.com/{org}/{app}/Cities/Miami/showrooms/CarShowrooms/Suzuki

Then, to retrieve the showrooms in Miami, you could perform:

curl https://api.usergrid.com/{org}/{app}/Cities/Miami/showrooms

Scott

See also the Apigee documentation.

Upvotes: 1

Related Questions