Let's say I want to represent a city in the US in the datastore: It might
look like this
Country --> State --> County --> City
In my REST API I want to be able to read all citys in a state, and then
update a city. How should the API look? Clearly, to update a city, I
would need the full ancestor path, which means somehow that information
needs to make it to the client so the client knows enough about the city in
order to make the update. I see two solutions here:
Scenario 1: Make sure the client has the datastore
*key. - *UPDATE API: cities/{cityKey} PUT
- Clean API, but there will be repetition of ancestor key data for
every descendant. If I read all the cities for a state, all the county key
info will be repeated in each city key.
Scenario 2: Make sure the client has the ancestor path as represented by
each
*id *- UPDATE API:
countries/{countryId}/states/{stateId}/counties/{countyId}/cities/{cityId}
- My main issue with this scenario is that the API is ugly and
unconventional, but it is more efficient because it avoids the ancestor key
data repetition
Which method is better? Or, is there another method to consider?
If there were a KeyFactory equivalent on the client that would allow for
the generation of a *key *from an ancestor path, that seems like one
compromise. Thoughts?
--
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit
https://groups.google.com/d/msgid/google-appengine/3c99f141-ad44-47d6-97e8-19340b928e7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.