View our GitHub

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

Edit Page

Find One (Blueprint)

Returns a single record from the model as a JSON Object.

GET /:model/:id

The findOne() blueprint action returns a single record from the model (given by :model) as a JSON object. The specified id is the primary key of the desired record.

If the action was triggered via a socket request, the requesting socket will be "subscribed" to the returned record. If the record is subsequently updated or deleted, a message will be sent to that socket's client informing them of the change. See the docs for .subscribe() for more info.

Parameters

Parameter Type Details
id
-or-
The desired record's primary key value

e.g. this would be 7 if the URL path is /product/7.
callback Optional. 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

Find the purchase with id #1:

GET /purchase/1
Expected Response
{
   "amount": 49.99,
   "id": 1,
   "createdAt": "2013-10-18T01:22:56.000Z",
   "updatedAt": "2013-10-18T01:22:56.000Z"
 }

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