jsonapi-serializer icon indicating copy to clipboard operation
jsonapi-serializer copied to clipboard

can't keep specific attribute intact

Open jrdn91 opened this issue 7 years ago • 0 comments

I'm having a hard time understanding how to keep a specific attribute intact

I have a handful of attributes that are camelCased and then one that comes in sometimes that is __id__

It's not always there but when it is I need to pass it back to my client app as is

Here is what I have setup now but I can't get this to work

const TagSerializer = new JSONAPISerializer('tags', {
  attributes: ['firstName', 'lastName', 'template',{
    id: '__id__',
    keyForAttribute: (attr) => {
      return '__id__';
    },
    nullIfMissing: true
  }],
  keyForAttribute: 'camelCase',
});

The __id__ is not always there and doesn't get saved in my database

jrdn91 avatar Mar 15 '18 02:03 jrdn91