Skip to content

Instantly share code, notes, and snippets.

Last active December 28, 2016 18:40
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Commented out stuff from sails-docs/concepts/ORM/



Use this attribute as the the primary key for the record. Only one attribute per model can be the primaryKey. Note: This should never be used unless autoPK is set to false.

attributes: {
  uuid: {
    type: 'string',
    primaryKey: true,
    required: true


Move this into automigrations


If supported in the adapter, can be used to define the size of the attribute. For example in MySQL, size can be specified as a number (n) to create a column with the SQL data type: varchar(n).

attributes: {
  name: {
    type: 'string',
    size: 24


Omitting index from docs for now, because it is not officially supported in Sails v1 / Waterline 0.13. This could change in a future minor version release of Waterline (To get involved, please see


Will create a simple index in the underlying datastore for faster queries if available. This is only for simple indexes and currently dosn't support compound indexes. For these you will need to create them yourself or use a migration.

There is currently an issue with adding indexes to string fields. Because Waterline performs its queries in a case insensitive manner we are unable to use the index on a string attribute. There are some workarounds being discussed but nothing is implemented so far. This will be updated in the near future to fully support indexes on strings.

attributes: {
  email: {
    type: 'string',
    index: true



A special validation property which only saves data which matches a whitelisted set of values.

attributes: {
  state: {
    type: 'string',
    enum: ['pending', 'approved', 'denied']


These are not ready for prime-time yet, but listing them here so they're easy to reference and add to official docs later:


An example value for this attribute, e.g. "Albus Dumbledore".


A custom validation message to use when any validations fail for this attribute.

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