Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikermcneil/1b87af6b6a8458254deb83a6d1cf264f to your computer and use it in GitHub Desktop.
Save mikermcneil/1b87af6b6a8458254deb83a6d1cf264f to your computer and use it in GitHub Desktop.
An unrealistic (but fully-expanded) example of the expected return value from parseBlueprintOptions() (See http://sailsjs.com/documentation/reference/configuration/sails-config-blueprints)

Unrealistic, fully-expanded example of the expected return value from parseBlueprintOptions()

For more information, see http://sailsjs.com/documentation/reference/configuration/sails-config-blueprints (or https://github.com/balderdashy/sails-docs/tree/1.0/reference/sails.config/sails.config.blueprints.md)

{
  // The model identity, REQUIRED.
  using: 'user',

  // Search criteria, used by `find`, `findOne`, `destroy`, `populate` and `update`.
  // Note that for all except `find`, the `where` clause must include only the model's primary key.
  criteria: {
    where: {
      age: 25
    },
    // Skip, limit and sort will be ignored by all blueprints except `find`.
    skip: 5,
    limit: 10,
    sort: [{score: 'desc'}]
  },

  // Dictionary of associations to populate.  Each key should be an attribute name,
  // with the value set to a criteria object like the one above.
  populates: {
    pets: {
      where: {
        breed: 'cat'
      },
      sort: [{name: 'asc'}],
      limit: 5
    }
  },

  // Values for a new record, valid only for the `create` blueprint.
  newRecord: {
    name: 'bob',
    age: 30,
    score: 10,
    pets: [3, 65]
  },

  // Values for an updated record, valid only for the `update` blueprint.
  valuesToSet: {
    name: 'joe',
    age: 12,
  },

  // Name of a plural association attribute to modify.
  // Valid for `add`, `remove`, `replace` and `populate`.
  alias: 'pets',

  // The primary key of the record containing a plural association to modify.
  // Valid for `add`, `remove`, and `replace`.
  targetRecordId: 123,

  // The primary keys of associated records, for use in `add`, `remove` and `replace`.
  // For `add` and `remove` this array must contain only one value.
  associatedIds: [34, 12]

}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment