Advertisement
francfooter

Sample Sails Models

May 28th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Company.js
  2. module.exports = {
  3.     migrate: 'safe',
  4.     tableName: 'companies',
  5.     attributes : {
  6.         id: {type: 'INTEGER', primaryKey: true},
  7.         name: 'STRING',
  8.         users: {
  9.             collection: 'user',
  10.             via: 'company'
  11.         }
  12.     }
  13. };
  14.  
  15. // User.js
  16. module.exports = {
  17.   migrate: 'safe',
  18.   tableName: 'users',
  19.   attributes: {
  20.         id: {type: 'INTEGER', primaryKey: true},
  21.         firstName: {type: 'STRING', required: true, len:50},
  22.         lastName: {type: 'STRING', required: true, len:50},
  23.         companyId: 'INTEGER',
  24.         company: {
  25.             model: 'company',
  26.             columnName: 'companyId'
  27.         }
  28.   }
  29. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement