SHARE
TWEET

Untitled

a guest Jan 26th, 2019 128 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 'use strict'
  2.  
  3. import {
  4.   uuid
  5. } from '../utils/uuid'
  6.  
  7. module.exports = (sequelize, DataTypes) => {
  8.   const User = sequelize.define('User', {
  9.     uuid: {
  10.       allowNull: false,
  11.       unique: true,
  12.       type: 'BINARY(16)',
  13.       defaultValue: () => Buffer(uuid(), 'hex'),
  14.       get: function () {
  15.         return Buffer.from(this.getDataValue('uuid')).toString('hex')
  16.       }
  17.     },
  18.     email: {
  19.       allowNull: false,
  20.       unique: true,
  21.       type: DataTypes.STRING,
  22.       validate: {
  23.         isEmail: true,
  24.       },
  25.     },
  26.     password: {
  27.       allowNull: false,
  28.       type: DataTypes.STRING,
  29.     }
  30.   }, {
  31.     tableName: 'users',
  32.     timestamps: true,
  33.   })
  34.  
  35.   User.associate = function(models) {
  36.     // associations
  37.   }
  38.  
  39.   // hooks
  40.  
  41.   return User
  42. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top