Skip to content

Instantly share code, notes, and snippets.

@rachaelshaw
Created February 16, 2017 18:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rachaelshaw/f5bf442b2171154aa6021846d1a250f8 to your computer and use it in GitHub Desktop.
Save rachaelshaw/f5bf442b2171154aa6021846d1a250f8 to your computer and use it in GitHub Desktop.
An example model definition for the Sails framework documentation - http://sailsjs.com/documentation
/**
* Parrot.js
* 
* @description :: The set of parrots registered in our app.
* @docs        :: http://sailsjs.com/documentation/concepts/models-and-orm/models
*/

module.exports = {

  attributes: {
    
    // e.g. "Polly"
    name: {
      type: 'string'
    },
    
    // e.g. 3.26
    wingspan: {
      type: 'number',
      required: true,
      columnType: 'FLOAT'
    },
    
    // e.g. "cm"
    wingspanUnits: {
      type: 'string',
      isIn: ['cm', 'in', 'm', 'mm'],
      defaultsTo: 'cm'
    },
    
    // e.g. [{...}, {...}, ...]
    knownDialects: {
      collection: 'Dialect'
    } 
  }
};
@benticarlos
Copy link

How can I create a date type attribute?
date: {
type: 'string',
columnType: 'Date'
}

^
It may be so??

Copy link

ghost commented May 24, 2019

Three is a section for "Embeds" in the models generated by sails . What is it all about, and how do we use them?

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