View our GitHub

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

Edit Page

Update (Blueprint)

Updates an existing record. Attributes to change should be sent in the HTTP body as form-encoded values or JSON.

PUT /:model/:id

Updates the model instance which matches the id parameter. Responds with a JSON object representing the newly updated instance. If a validation error occurred, a JSON response with the invalid attributes and a 400 status code will be returned instead. If no model instance exists matching the specified id, a 404 is returned.

Parameters

Parameter Type Details
id
(required)

-or-
The primary key value of the record to update.

e.g. PUT /product/5
*


For POST (RESTful) requests, pass in body parameters with the same name as the attributes defined on your model to set those values on the desired record. For GET (shortcut) requests, add the parameters to the query string.
callback If specified, a JSONP response will be sent (instead of JSON). This is the name of the client-side javascript function to call, passing results as the first (and only) argument

e.g. ?callback=myJSONPHandlerFn

Example

Change Applejack's hobby to "kickin":

PUT /pony/47

{
  "hobby": "kickin"
}
Expected Response
{
  "hobby": "kickin",
  "id": 47,
  "name": "AppleJack",
  "createdAt": "2013-10-18T01:23:56.000Z",
  "updatedAt": "2013-11-26T22:55:19.951Z"
}

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