Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 'use strict'
- export default (sequelize, DataTypes) => {
- const Account = sequelize.define('Account', {
- firstName: {
- type: DataTypes.STRING,
- allowNull: false,
- validate: {
- not: /[`~@#$^*&!,<>;':"/[\]|{}()=+_-]/,
- is: /^[a-zA-Z\s]*$/
- }
- },
- lastName: {
- type: DataTypes.STRING,
- allowNull: false,
- validate: {
- not: /[`~@#$^*&!,<>;':"/[\]|{}()=+_-]/,
- isAlpha: true,
- }
- },
- email: {
- type: DataTypes.STRING,
- allowNull: false,
- unique: true,
- validate: {
- isEmail: true,
- }
- },
- phoneNumber: {
- type: DataTypes.STRING,
- allowNull: false,
- unique: true,
- validate: {
- isNumeric: true,
- not: /[`~@#$^*&!,<>;':"/[\]|{}()=+_-]/,
- }
- },
- username: {
- type: DataTypes.STRING,
- allowNull: false,
- unique: true,
- validate: {
- not: /[`~@#$^*&!,<>;':"/[\]|{}()=+]/,
- }
- },
- password: {
- type: DataTypes.STRING,
- allowNull: false,
- validate: {
- isAlphanumeric: true,
- }
- },
- isPending: {
- type: DataTypes.BOOLEAN,
- defaultValue: true
- },
- isSuspended: {
- type: DataTypes.BOOLEAN,
- defaultValue: false
- }
- },
- {
- classMethods: {
- associate: function (models) {
- // =====================
- // Settings Associations
- // =====================
- Account.hasOne(models.Address);
- Account.hasOne(models.WorkExperience);
- Account.hasOne(models.EdExperience);
- Account.hasOne(models.Role)
- // =====================
- // Chat Associations
- // =====================
- // .hasMany(models.Chat)
- Account.belongsToMany(models.Chat, {
- through: {
- model: models.ParticipantsInChat,
- unique: false
- }
- })
- Account.hasMany(models.Message)
- // =====================
- // x Associations
- // =====================
- }
- }
- })
- return Account;
- }
- // module.exports = function(sequelize, DataTypes) {
- // const Account = sequelize.define('Account', {
- // email: {
- // type: DataTypes.STRING
- // }
- // }, {
- // classMethods: {
- // associate: function(models) {
- // // Account.hasMany(models.Chat);
- // Account.belongsToMany(models.Chat, {
- // through: {
- // model: models.ParticipantsInChat,
- // unique: false
- // },
- // });
- // Account.hasMany(models.Message);
- // }
- // }
- // });
- // return Account;
- // };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement