Prometheus
Prometheus

Reputation: 81

Sails JS Blueprints allow Update operations on primary key

Sails JS creates CRUD for the defined models using blueprints. To do an update you do Model/Update/:id and then pass in the values you want to change. However this allows changing of the primary key. Is there a way to disallow this without defining custom CRUD?

Upvotes: 1

Views: 118

Answers (1)

Matthew Arkin
Matthew Arkin

Reputation: 4648

You could add some validation to the model that ensure the new id equals the old id.

As of 2014-11-11 Waterline offers a beforeUpdate hook, in that hook you could ensure that id isn't part of the fields to be updated and if so just delete it from the object.

Upvotes: 1

Related Questions