tasks-backend/db/models/index.js
2019-07-11 23:26:55 +02:00

39 lines
855 B
JavaScript
Executable File

const Task = require('./task')
const Project = require('./project')
const User = require('./user')
const Article = require('./article')
const Tag = require('./tag')
const Comment = require('./comment')
const Vote = require('./vote')
User.hasMany(Article)
User.hasMany(Comment)
User.hasMany(Vote)
Project.hasMany(Task)
Task.belongsTo(Project)
Article.hasMany(Comment)
Article.belongsToMany(Tag, { through: 'articleTags' })
Article.belongsTo(User)
Tag.belongsToMany(Article, { through: 'articleTags' })
Comment.belongsTo(Article)
Comment.belongsTo(User)
Comment.hasMany(Vote)
Vote.belongsTo(Comment)
Vote.belongsTo(User)
User.belongsToMany(Project, { through: 'projectUser' })
Project.hasMany(User)
Task.belongsToMany(User, { through: 'userTask' })
User.hasMany(Task)
module.exports = {
Task,
Project,
User,
Article,
Tag,
Comment,
Vote,
}