2
votes

I have a model attribute in my Sails.js project that I want to set back to its default value. With default value I mean what I specified using defaultsTo in the model file.

I've tried something like:

model.update({id:exampleId}, {myAttribute: null})

model.update({id:exampleId}, {myAttribute: default})

How can I make a model attribute go back to its default value from a controller?

1

1 Answers

3
votes

You can get this value off the sails object.

MODEL.update(id,{myAttribute:sails.models.MODEL.myAttribute.defaultsTo})