Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Decorate models #2729

Closed
crunchtime-ali opened this issue Mar 7, 2015 · 2 comments
Closed

Decorate models #2729

crunchtime-ali opened this issue Mar 7, 2015 · 2 comments
Assignees
Labels
orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. question

Comments

@crunchtime-ali
Copy link

If you want only a subset of properties from a model you may select the properties in question with select: ['name', 'favoriteColor']

While we can easily use this in our blueprints it is difficult to protect against injection or implement whitelisting of parameters. Someone could always alter the query to select all columns.

Therefore I suggest adding means to "decorate" models. You got a model but define a "sub-model" which only contains a subset of its properties.
They should also be able to be bound to policies (a registered user gets different properties than an authenticated one).

@Josebaseba
Copy link
Contributor

http://sailsjs.org/#!/documentation/concepts/ORM/Validations.html

Check the protected: true validation. I think that that can work as you want.

@tjwebb tjwebb added question orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. labels Apr 8, 2015
@CWyrtzen CWyrtzen assigned jdcauley and particlebanana and unassigned jdcauley Jul 9, 2015
@particlebanana
Copy link
Contributor

The concept of beforeFind and afterFind have been discussed a few places in Waterline. Right now it looks like some solution is scheduled for 0.11 of Waterline. You can start here: https://github.com/balderdashy/waterline/issues/923 and follow the rabbit hole for more discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
orm Related to models, datastores, orm config, Waterline, sails-hook-orm, etc. question
Development

No branches or pull requests

5 participants