View our GitHub

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

Edit Page

Populate (Blueprint)

If the specified association is plural ("collection"), this action returns the list of associated records as a JSON array of objects. If the specified association is singular ("model"), this action returns the associated record as a JSON object.

GET /:model/:record/:association


Populate the cashier who conducted purchase #47.

Using jQuery:

$.get('/purchase/47/cashier', function (purchase) {

Using Angular:

.then(function (purchase) {


io.socket.get('/purchase/47/cashier', function (purchase) {

Using cURL:

curl http://localhost:1337/purchase/47/cashier

Should return:

  "amount": 99.99,
  "id": 47,
  "cashier": {
    "name": "Dolly",
    "id": 7,
    "createdAt": "2012-05-14T01:21:05.000Z",
    "updatedAt": "2013-01-15T01:18:40.000Z"
  "createdAt": "2013-10-14T01:22:00.000Z",
  "updatedAt": "2013-10-15T01:20:54.000Z"


  • The example above assumes "rest" blueprints are enabled, and that your project contains at least an empty 'Employee' model as well as a Purchase model with an association attribute: cashier: {model: 'Employee'}. You'll also need at least an empty PurchaseController and EmployeeController. You can quickly achieve this by running:

    $ sails new foo
    $ cd foo
    $ sails generate api purchase
    $ sails generate api employee

    ...then editing api/models/Purchase.js.

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