This commit is contained in:
@@ -33,6 +33,7 @@ const Game = require('./Game');
|
||||
const GameType = require('./GameType');
|
||||
const LessonComponentProgress = require('./LessonComponentProgress');
|
||||
const LessonLeaderboard = require('./LessonLeaderboard');
|
||||
const LessonStory = require('./LessonStory');
|
||||
|
||||
// Group 3.2: Vocabulary System (NEW)
|
||||
const Vocab = require('./Vocab');
|
||||
@@ -162,6 +163,24 @@ const setupRelationships = () => {
|
||||
Chapter.hasMany(Lesson, { foreignKey: 'chapter_id', as: 'lessons' });
|
||||
Lesson.belongsTo(Chapter, { foreignKey: 'chapter_id', as: 'chapter' });
|
||||
|
||||
// Lesson <-> Story (N:N through LessonStory)
|
||||
Lesson.belongsToMany(Story, {
|
||||
through: LessonStory,
|
||||
foreignKey: 'lesson_id',
|
||||
otherKey: 'story_id',
|
||||
as: 'stories'
|
||||
});
|
||||
Story.belongsToMany(Lesson, {
|
||||
through: LessonStory,
|
||||
foreignKey: 'story_id',
|
||||
otherKey: 'lesson_id',
|
||||
as: 'lessons'
|
||||
});
|
||||
|
||||
// Direct access to pivot table
|
||||
LessonStory.belongsTo(Lesson, { foreignKey: 'lesson_id', as: 'lesson' });
|
||||
LessonStory.belongsTo(Story, { foreignKey: 'story_id', as: 'story' });
|
||||
|
||||
// Lesson Progress relationships
|
||||
LessonComponentProgress.belongsTo(UsersAuth, { foreignKey: 'user_id', as: 'user' });
|
||||
LessonComponentProgress.belongsTo(Lesson, { foreignKey: 'lesson_id', as: 'lesson' });
|
||||
@@ -295,6 +314,7 @@ module.exports = {
|
||||
GameType,
|
||||
LessonComponentProgress,
|
||||
LessonLeaderboard,
|
||||
LessonStory,
|
||||
|
||||
// Group 3.2: Vocabulary System (NEW)
|
||||
Vocab,
|
||||
|
||||
Reference in New Issue
Block a user