Search code examples
node.jsmongodbsails.jssails-mongo

Sails JS Model Rest API


I'm new to sails.js and find something strange. I have create a model user like :

sails generate api user

So i have access to :

http://localhost:1337/user/

and

http://localhost:1337/user/create?name=joe&test=true

But why sails allow me to add any fields I want in the model like :

http://localhost:1337/user/create?name=joe&test=true&toto=ok&titi=okToo

toto and okToo are not under my model in api/model/User.js:attributs

I miss something maybe if anyone can help me to understand this. For me sails.js have to save only fields i put on model:attributs file or throw an exception


Solution

  • You can limit the creation of fields to only those you specific in the model. Sails has this feature to allow for quickly mocking up your site.

    http://sailsjs.org/#/documentation/concepts/ORM/model-settings.html?q=schema