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
In your case, you can add options when you attach the plugin to your CompanySchema like so:
constjsonapi=require('@carsondarling/mongoose-jsonapi');CompanySchema.plugin(jsonapi,{serializer: {admins: {ref: 'id',attributes: ['firstName','lastName'],// You'll have to customize this to serialize what you want},// Specify the JSONAPI type for the admins attribute onlytypeForAttribute(attribute){if(attribute==='admins')return'User';returnundefined;},},});
That should give you a decent starting point, and digging into the options from SeyZ/jsonapi-serializer will give you a better idea of what's possible.
How would this work with relationship to other models i.e
The plugin returns the first level model without problem the second one is returned as plain JSON
My initial idea is to have to
.serialize
for every model.Unfortunately it did not work as expected. Any thoughts?
The text was updated successfully, but these errors were encountered: