scoutforpets / jsonapi-mapper

JSON API-Compliant Serialization for your Node ORM
The Unlicense
42 stars 24 forks source link

Handle idAttribute as an array #96

Closed chamini2 closed 7 years ago

chamini2 commented 7 years ago

The idea of this PR is to handle idAttribute values from Bookshelf that are arrays, these are a little bit supported and my team is currently using them for some stuff.

Thought we could add it even though it's not official.


What should we return for id? I set it to return the a string of the ids joined by commas ,, but could be a differently formatted string.

NOTE: JSONAPI specifies that id MUST be a string.

chamini2 commented 7 years ago

@ShadowManu remember that

_.matches({data: {attributes: {decription: '...'}})({data: {attributes: {decription: '...', name: 'Matteo'}})

returns true since matches matches as having at least all the properties in the first parameter, but maybe there are more properties in the second parameter.

So we have the same setup, but expect different things; like, we don't check for id nor type in the one that checks omit; also, we expect the result not to contain the idAttributes (name, email).

ShadowManu commented 7 years ago

@chamini2 got it. LGTM then.