You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

16 lines
559 B

  1. /**
  2. * Associate DB Model relations
  3. */
  4. module.exports = db => {
  5. db.User.belongsToMany(db.Group, { through: 'userGroups' })
  6. db.Group.belongsToMany(db.User, { through: 'userGroups' })
  7. db.Group.hasMany(db.Right)
  8. db.Right.belongsTo(db.Group)
  9. db.Document.belongsToMany(db.Tag, { through: 'documentTags' })
  10. db.Document.hasMany(db.Comment)
  11. db.Tag.belongsToMany(db.Document, { through: 'documentTags' })
  12. db.File.belongsTo(db.Folder)
  13. db.Folder.hasMany(db.File)
  14. db.Comment.belongsTo(db.Document)
  15. db.Comment.belongsTo(db.User, { as: 'author' })
  16. }