Sails JS Blueprints allow Update operations on primary key

151 views Asked by At

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?

1

There are 1 answers

0
Matthew Arkin On

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.