Advertisement
Guest User

Untitled

a guest
Jul 17th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. export default (sequelize, DataTypes) => {
  2. const Users = sequelize.define('Users', {
  3. username: {
  4. allowNull: false,
  5. type: DataTypes.STRING,
  6. unique: true,
  7. validate: {
  8. notEmpty: true
  9. }
  10. },
  11. phone: {
  12. allowNull: false,
  13. type: DataTypes.STRING,
  14. validate: {
  15. not: ['[a-z]', 'i']
  16. }
  17. },
  18. email: {
  19. allowNull: false,
  20. type: DataTypes.STRING,
  21. unique: true,
  22. validate: {
  23. isEmail: true
  24. }
  25. },
  26. password: {
  27. allowNull: false,
  28. type: DataTypes.STRING,
  29. unique: true,
  30. validate: {
  31. notEmpty: true
  32. }
  33. }
  34. });
  35. Users.associate = (models) => {
  36. Users.belongsToMany(models.Groups, {
  37. through: 'GroupUsers',
  38. as: 'groups',
  39. foreignKey: 'userId'
  40. });
  41. };
  42. return Users;
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement