WagnerMatosUK
WagnerMatosUK

Reputation: 4429

What methods are available in a Sails' generated model/controller?

When you create a model/controller using sails generate user, which models are available? For instance, I know there some like basic CRUD, etc, but how to see all available methods?

PS: Unless I got it all wrong and there are no CRUD methods at all. I'm still learning Sails, so please forgive if its a silly question.

Upvotes: 0

Views: 1663

Answers (1)

bredikhin
bredikhin

Reputation: 9035

Basically, there are two groups of actions provided by Sails.js blueprints for a newly generated model/controller pair:

  1. REST API: get /:controller/:id?, post /:controller, put /:controller/:id, delete /:controller/:id. These are classic REST set that should be the one being used in production. You can enable/disable these blueprints via rest property in config/controllers.js.
  2. CRUD actions aka shortcuts: /:controller/find/:id?, /:controller/create, /:controller/update/:id, /:controller/destroy/:id. Inspired, by Rails' RESTful conventions, the shortcuts provide a way to call all the REST actions from browser address string, using GET HTTP method only, which can be very handy for developers. These can be enabled/disabled using shortcuts property in config/controllers.js, and it's a good idea to disable them in production (for example, using local environment settings (config/local.js)).

Upvotes: 2

Related Questions