View our GitHub

Please visit sails-docs on GitHub to view documentation on your mobile device.

Edit Page

* .save(callback)


The save() method updates your record in the database using the current attributes. It then returns the newly saved object in the callback.



Description Accepted Data Types Required ?
1 Callback function Yes

Callback Parameters

Description Possible Data Types
1 Error Error
2 Saved Record { }

Example Usage


    // Grab a record off the top of the returned array and save a new attribute to it
    var getOneRecord = myRecords.pop(); = 'Hank';
        console.log('User with ID '' now has name ';

// User with ID 1 now has name Hank

// Don't forget to handle your errors.
// Don't forget to abide by the rules you set in your model


This is an instance method. Currently, instance methods ARE NOT TRANSACTIONAL. Because of this, it is recommended that you use the equivalent model method instead.

Is something missing?

If you notice something we've missed or could be improved on, please follow this link and submit a pull request to the sails-docs repo. Once we merge it, the changes will be reflected on the website the next time it is deployed.


We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book