I've been developing an app for about a year now, so I started it mid-2014 and have been upgrading ember.js and ember-cli as things move forward on those projects. I'm at Ember 1.11 now.
My JSON API returns a main projects
object, along with other sideloaded objects (like projectStatus). What I can't understand is, since I don't have any adapters or serializers that specify this, how I'm it's able to use the returned JSON, because it looks like this:
{
"projects" : {
"id": 4462875
"projectName" : "New business from Acme",
"projectDescription" : "Just another great project",
"pmlinks" : [ 1, 2],
"statusLinks" : [ 1440 ],
"commentsLinks" : [ 39 ]
},
"projectResources" : [ {
"id" : 1,
"name" : "Wile E. Coyote"
}, {
"id" : 2,
"name" : "Roadrunner"
}],
"projectComments" : [ {
"id" : 39,
"projectComment" : "started the project",
} ],
"projectStatuses" : [ {
"id" : 1440,
"status" : "G",
"trending" : "N",
"comment" : null,
"lastModifiedDate" : "2015-07-17T13:46:11.037+0000",
"project" : 4462875
} ],
}
I can't find anything in the Ember docs that reccomend this "*Links" format for the relationships, and in fact it suggests using something more like status_ids
. But the example it shows doesn't use _ids
so I'm even more confused.
Here's a snippet of my project model:
statusUpdates: DS.hasMany('projectStatus'),
projectComments: DS.hasMany('projectComment'),
projectResources: DS.hasMany('projectResource'),
What I'm trying to figure out is with my new belongsTo relationship to schedule
, how should the JSON be formatted from the API? It seems to work if the project object has a property like this "scheduleLinks": [10]
but not if it's like "schedule": 10
or "schedule_id": 10
and that seems to be what the documentation says should work.
Aucun commentaire:
Enregistrer un commentaire