jsonapi-serializer
jsonapi-serializer copied to clipboard
Relations where the id isn't id
const WidgetsSerializer = new JSONAPISerializer('widgets', {
// id: 'guid',
attributes: ['name', 'bars'],
bars: {
// ref: 'guid',
ref: 'id',
attributes: ['bar_name'],
included: true,
},
So, basically this. in the database, the widgets table has an id of 'guid' (a UUID) and, there is a related table bars that has an id of 'guid'.
So, if I try to use "guid" in my Sequelize Models.. and then tell jsonapi-serializer to ref on guid.. the included: [] is always empty, even though the relationships hash is populated.
If I make all my id's be named, literally, 'id', then it all works as expected in the docs/examples etc
Is tehre possibly (I can't find it) an assumption somewhere that builds the included: [] that assumes 'id' versus the ref name?
(or am I just using it wrong/I don't see this in the docs hah)