Two Ember guides on JSON API conventions to use with Ember Data are contradictory:
RESTAdapter guide
This guide says that relationships should be captured in the API by appending “_ids” to the related model name, as in:
{
"post": {
"comment_ids": [1, 2, 3]
}
}
It also shows that the ids are integers, and says that API property keys should be underscored versions of their Ember model equivalents.
Connecting to an HTTP Server guide
This guide says that relationships should be captured in the API without appending “_ids”:
"post": {
"comments": ["1", "2"],
}
It also shows that the ids are strings. If you look at the link, it also sort of implies that related records need to be sideloaded into the API response, which they do not.
The Connecting to an HTTP Server guide is linked in the main sidebar of the Ember guides site. I cannot find a link to the RESTAdapter Guide in this sidebar, but it comes up on Google. The RESTAdapter Guide contains generally more information than the Connecting to an HTTP Server Guide. Which guide am I supposed to believe?
I remember trying to work with Ember months ago and encountering similar issues with the JSON API conventions; at the time, I believe the guides linked to jsonapi.org, which specifies yet ANOTHER standard.
Questions
- I am finding that Ember data is not capturing my properties when the API keys them in the underscored form, but they are correctly captured when the API uses exactly the same key as is used in my Ember model. This is in direct contradiction of the RESTAdapter guide. How should the API key properties?
- Should ids be strings or integers, or does it not matter?
- Should “_ids”/“_id” be appended to properties holding the ids of related records?
- Is there some simple location that I can always consult for a complete specification of the conventions used by the Ember Data REST Adapter?
Versions
I am currently using the latest builds of both Ember and Ember Data:
- 1.3.0-beta.2 (Ember)
- 1.0.0-beta.3 (Ember Data)
I decided to use the latest after having needed to update versions several times in order to make some of my code work. Not sure whether using the latest betas is a good idea though. What versions of Ember can I expect Ember Data to work properly with? The Bower repository of the latest Ember data has ~1.0.0 for its Ember version specification. I found that I needed a version of Ember >1.1.0 to fix certain bugs. Is this safe, or do I really need to confine myself to Ember ~1.0.0 with Ember Data?