You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Your data sample does not come close to representing what the JSON-API spec defines.
You'll most likely want to create a parse function on your Comment model that would transform user: { username: 'Bob' } into { user: { id: 2 } } then where you create the relation between User and Comment set parse: trueOR you could set the idAttribute on your User model to be username which may cause issues elsewhere when fetching/saving.
We've been using Backbone Relational to model our ORM relationship in the front end for instance:
That has been working great using models such as this in the front end:
However now our api has changed and respecting more of the JSON-API Spec so the data from the back end is encapsulated inside of 'data'.
How can we instruct backbone relational to get the data for the 'comments' relation from .data instead of mapping the json structure directly?
For the ''class User'' we can implement the parse method like so
But how do we do this for the comments relation??
The text was updated successfully, but these errors were encountered: