Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Created by Mel on 04/08/2016.
- */
- module.exports = function(db, Sequelize)
- {
- var User = db.define('user',
- {
- id: {
- type: Sequelize.UUID,
- defaultValue: Sequelize.UUIDV1,
- primaryKey: true
- },
- firstname: {
- type: Sequelize.STRING,
- allowNull: false,
- validate: {
- len: {
- args: 3,
- msg: "First Name must be at least 3 characters in length"
- }
- }
- },
- lastname: {
- typahe: Sequelize.STRING,
- allowNull: false,
- validate: {
- len: {
- args: 3,
- msg: "Last Name must be at least 3 characters in length"
- }
- }
- },
- biography: {
- type: Sequelize.STRING,
- allowNull: true
- },
- birthdate: {
- type: Sequelize.DATE,
- allowNull: true
- },
- phone: {
- type: Sequelize.STRING,
- allowNull: true
- },
- city: {
- type: Sequelize.STRING,
- allowNull: true
- },
- country: {
- type: Sequelize.STRING,
- allowNull: true
- },
- postal_code: {
- type: Sequelize.STRING,
- allowNull: true
- },
- road_number: {
- type: Sequelize.STRING,
- allowNull: true
- },
- road_name: {
- type: Sequelize.STRING,
- allowNull: true
- },
- email: {
- type: Sequelize.STRING,
- allowNull: false,
- unique: true,
- validate: {
- len: {
- args: [6, 128],
- msg: "Email address must be between 6 and 128 characters in length"
- },
- isEmail: {
- msg: "Email address must be valid"
- }
- }
- },
- password: {
- type: Sequelize.STRING,
- allowNull: false,
- validate: {
- len: {
- args: 3
- }
- }
- },
- activated: {
- type: Sequelize.BOOLEAN,
- defaultValue: 0
- },
- ban: {
- type: Sequelize.BOOLEAN,
- defaultValue: 0
- },
- ban_start: {
- type: Sequelize.DATE,
- allowNull: true
- },
- ban_end: {
- type: Sequelize.DATE,
- allowNull: true
- },
- role: {
- type: Sequelize.ENUM('user', 'admin')
- },
- passwordAt: {
- type: Sequelize.DATE,
- allowNull: true
- },
- lastSeen: {
- type: Sequelize.DATE,
- allowNull: true
- },
- activatedAt: {
- type: Sequelize.DATE,
- allowNull: true
- },
- resetAt: {
- type: Sequelize.DATE,
- allowNull: true
- },
- resetKey: {
- type: Sequelize.STRING
- },
- activationKey:
- {
- type: Sequelize.STRING
- }
- },
- {
- classMethods:
- {
- associate: function(models)
- {
- User.hasMany(models.walls);
- User.hasMany(models.posts);
- User.hasMany(models.groups);
- User.hasMany(models.payments);
- User.hasMany(models.room_locations);
- User.hasMany(models.conversations);
- User.hasMany(models.conversation_users);
- User.belongsToMany(models.users, {
- as: 'friends',
- through: 'friend',
- foreignKey: 'userId',
- otherKey: 'friendId'
- });
- }
- }
- });
- return User;
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement