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.

18 lines
573 B

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