Suppose we have a rest API to get back some items located at /items which returns a JSON array like so
[ {....},{...},{...} .... {...}]
suppose that items/{id} returns the representation of the item with id {id}
to get to item 4 it is possible to do it in two ways:
Case 1: get /items and then search the response for an item with id #4
Case 2: get /item/4
should the representation to returned by case 1 be identical as the representation returned by case 2?
EDIT 1 for example /dogs could return an array of dog resources where only the name and the id are populated and /dogs/4 could return full details for a dog resource.
Short answer
You can return different structures from Collection and from Model.
Long answer
You can return in your JSON whatever you want, Backbone will build an entity of your
Modelusing the data provided by the JSON, Backbone will adapt the created instance to the data provided, merging it with the declaredModel.defaults.You can even, for example, return different JSON structure for this two queries:
I understand your concern, you are trying to
fetcha bunch of objects with very low data detail and thenfetchthe full data for a concrete instance when is needed.I don’t see any problem on it.
Try to mark your uncompleted Models to not using them in the detailing Views without fetching the whole data.