how to set default value for a field in Sails models using Waterline ORM?

Gagandeep Singh picture Gagandeep Singh · May 3, 2014 · Viewed 12.5k times · Source

A very simple question but I am unable to find the answer to it. So in my Sails app I have a User model and I am trying to make a boolean field with a default value to be False.

Is there a way to specify defaults like some kind of default attribute etc??

I want something like this:

is_admin: {
        type: 'boolean',
        default: 'false'
    }

Thanks for your time.

Answer

zieglar picture zieglar · May 3, 2014

use defaultsTo look this Waterline Docs