const Player = require("./Player"); const Message = require("./Message.js"); const Friend = require("./Friend"); const setupAssociations = () => { Message.belongsTo(Player, { as: "sender", foreignKey: "senderId", }); Message.belongsTo(Player, { as: "receiver", foreignKey: "receiverId", }); Player.hasMany(Message, { foreignKey: "senderId", }); Player.belongsToMany(Player, { through: Friend, as: "Friends", foreignKey: "playerId", otherKey: "friendId", }); }; module.exports = setupAssociations;