1
2
3
4
5
6
7
8
9
10
11
12
13
| let db = {};
db.sequelize = sequelize;
db.Sequelize = Sequelize;
db.User = require('./user')(sequelize, Sequelize);
db.Comment = require('./comment')(sequelize, Sequelize);
// foreignKey: 외래키. Comment table's column. / sourceKey: User table's id
db.User.hasMany(db.Comment, { foreignKey: 'commenter', sourceKey: 'id' });
// foreignKey: Comment table's column. / targetKey: User table's id
db.Comment.belongsTo(db.User, { foreignKey: 'commenter', targetKey: 'id' });
module.export = db;
|