View our GitHub

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

Edit Page

.create( values, [callback] )

Purpose

Creates a new instance of this model in the database.

Overview

Parameters

Description Accepted Data Types Required ?
1 Record(s) to Create {}, [{}] Yes
2 Callback function No

Callback Parameters

Description Possible Data Types
1 Error Error
2 Records Created {}, [{}]

Example Usage

// create a new record with name 'Walter Jr'

User.create({name:'Walter Jr'}).exec(function createCB(err, created){
  console.log('Created user with name ' + created.name);
});

// Created user with name Walter Jr
// Don't forget to handle your errors and abide by the rules you defined in your model

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.

Reference

We wrote a book!

Get early access to the book
with promotion code: mcneildoc

Get the Book