import User from './User.js';
import Log from './Log.js';
import Club from './Club.js';
import UserClub from './UserClub.js';
import DiaryDate from './DiaryDates.js';
import Participant from './Participant.js';
import Member from './Member.js';
import Activity from './Activity.js';

User.hasMany(Log, { foreignKey: 'userId' });
Log.belongsTo(User, { foreignKey: 'userId' });

User.belongsToMany(Club, { through: UserClub, foreignKey: 'userId' });
Club.belongsToMany(User, { through: UserClub, foreignKey: 'clubId' });

DiaryDate.belongsTo(Club, { foreignKey: 'clubId' });
Club.hasMany(DiaryDate, { foreignKey: 'clubId' });

DiaryDate.belongsToMany(Member, { through: Participant, as: 'participants' });
Member.belongsToMany(DiaryDate, { through: Participant, as: 'diaryDates' });

DiaryDate.hasMany(Activity, { as: 'activities', foreignKey: 'diaryDateId' });
Activity.belongsTo(DiaryDate, { as: 'diaryDate', foreignKey: 'diaryDateId' });


export { User, Log, Club, UserClub };
