R
R
Ruslan Shashkov2014-11-14 21:36:40
Node.js
Ruslan Shashkov, 2014-11-14 21:36:40

How to set up the required model fields for REST in Sails JS?

Let me explain a little: in Sails, by default, when creating an API via the CLI, a controller, model, and router are automatically created. Then we manually add the name , email , password fields to the model, and by default, when requested, say GET /users/ The API will automatically issue all the stuffing, along with passwords and other things.
Yes, it’s clear that you can write a hook function before displaying in the model, in which you can do something like: delete user.password;.
But if there are, say, 100 fields, why should I select them all from the database, because this increases the load on the database? I need all the data completely only at the GET /user/:id request, and only name and id would be enough in the list.
As far as I understood from the documentation, in Waterline there is no way to specify fields inModel.find(...).
How are things like this handled elegantly in Sails, how can an ORM be that dumb?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question