update
All checks were successful
Deploy to Production / deploy (push) Successful in 20s

This commit is contained in:
Ken
2026-02-27 09:38:39 +07:00
parent 9af45a7875
commit 6287a019e3
16 changed files with 2032 additions and 18 deletions

View File

@@ -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,