Advertisement
Guest User

Untitled

a guest
Mar 21st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict';
  2. module.exports = function(sequelize, DataTypes) {
  3.   var User = sequelize.define('User', {
  4.     user_id:{
  5.       type: DataTypes.INTEGER,
  6.       primaryKey: true,
  7.       autoIncrement: true
  8.     },
  9.     name: {
  10.       type: DataTypes.STRING,
  11.       allowNull: false
  12.     },
  13.     lastname: {
  14.       type: DataTypes.STRING,
  15.       allowNull: false
  16.     },
  17.     email: {
  18.       type: DataTypes.STRING,
  19.       unique: true
  20.     },
  21.     password: {
  22.       type: DataTypes.STRING,
  23.       allowNull: false
  24.     },
  25.     phone:{
  26.       type: DataTypes.INTEGER,
  27.       unique: true,
  28.       allowNull: false
  29.     },
  30.     paymentInfo: {
  31.       type: DataTypes.STRING,
  32.       allowNull: true
  33.     }
  34.   }, {
  35.     classMethods: {
  36.       associate: function(models) {
  37.         // associations can be defined here
  38.         User.hasMany(models.Group, {
  39.           as: 'groups',
  40.           foreignKey: 'group_id'
  41.         }),
  42.         User.hasMany(models.Friendship, {
  43.           as: 'friends',
  44.           foreignKey: 'friend_id'
  45.         })
  46.       }
  47.     }
  48.   });
  49.   return User;
  50. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement