Advertisement
Guest User

Untitled

a guest
Jan 27th, 2016
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. 'use strict';
  2.  
  3. module.exports = function(sequelize, DataTypes){
  4.  
  5. //Define the user table, and its columns, data types, attributes
  6. var User = sequelize.define('User', {
  7. user_id: {...},
  8. user_name: {...}
  9. },
  10. {
  11. //Define the constraints, such as foreign key
  12. classMethods:{
  13. associate: function(models){
  14. User.belongsToMany(models.Group),
  15. User.hasMany(models.Old_Password),
  16. }
  17. }
  18. });
  19.  
  20. return User;
  21. };
  22.  
  23. 'use strict';
  24.  
  25. module.exports = function(sequelize, DataTypes){
  26.  
  27. var Role = sequelize.define('Role',{
  28. role_id: {...},
  29. role_name:{...}
  30. },
  31. {
  32. //Define the constraints, such as foreign key
  33. classMethods:{
  34. associate: function(models){
  35. Role.belongsTo(models.User)
  36. }
  37. }
  38. });
  39.  
  40. return Role;
  41. };
  42.  
  43. var Group = connection.define('group', {
  44. group_id: {...},
  45. group_name: {...},
  46. }
  47. return Group;
  48. };
  49.  
  50. 'use strict';
  51.  
  52. module.exports = function(sequelize, DataTypes){
  53.  
  54. //Define the table, and its columns, data types, attributes
  55. var Old_Password = connection.define('Old_Password', {
  56. old_password_id: {...},
  57. old_password_value: {...}
  58. },
  59. {
  60. //Define the constraints, such as foreign key
  61. classMethods:{
  62. associate: function(models){
  63. Old_Password.hasOne(models.User)
  64. }
  65. }
  66. });
  67.  
  68. return Old_Password;
  69. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement