{"size": 694, "ext": "js", "max_stars_repo_path": "models/index.js", "max_stars_repo_name": "casukhelai/tech-blog", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "models/index.js", "max_issues_repo_name": "casukhelai/tech-blog", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "models/index.js", "max_forks_repo_name": "casukhelai/tech-blog", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 15.7727272727, "max_line_length": 46, "alphanum_fraction": 0.5864553314}
const User = require('./User');
const Post = require('./Post');
const Comment = require('./Comment');

// User Relationships
User.hasMany(Post,
    { 
        foreignKey: 'userName_id',
        onDelete: "CASCADE"
    }
);

User.hasMany(Comment, 
    {
        foreignKey: 'userName_id'
    }
);

// post belongs to user, but has many comments
Post.belongsTo(User,
    {
        foreignKey: 'userName_id'
    }
);
Post.hasMany(Comment,
    {
        foreignKey: 'post_id'
    }
);

// comment relationships
Comment.belongsTo(User, 
    {
        foreignKey: 'userName_id'
    }
);
Comment.belongsTo(Post, 
    {
        foreignKey: 'post_id'
    }
);

module.exports = { User, Post, Comment };
