Thursday 13 April 2017

How can I remove unwanted attributes from Sails.js (Waterline)?

Let's say I have a Waterline model with two parameters name and age, and some user POSTs a JSON with the parameters name, age, extra, holycow.

If the user POSTs this, it will persisted with those attributes removed (since I'm using schema: true on my model.

But if he's POSTing for an association, such as posting a comment to an image using the url POST image/:id/comment, I'd use in my controller .add() and then also return the input'd object in the response.

So in this case, I can't just send the object in the response with the extra attributes. I want it to be cleaned.

Is there a simple way to do this fast in Sails.js/Waterline? I want to leave only the attributes in my model.



via Felo Vilches

No comments:

Post a Comment