All files / learning/schemas content.schema.ts

100% Statements 25/25
80% Branches 16/20
100% Functions 0/0
100% Lines 21/21

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 541x 1x     1x   1x     1x     1x     1x     1x 1x     1x   1x     1x     1x     1x     1x     1x     1x     1x     1x     1x 1x  
import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document, Schema as MongooseSchema } from 'mongoose';
 
@Schema({ timestamps: true, collection: 'learning_modules' })
export class CourseModule extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'Course', required: true, index: true })
  courseId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  title: string;
 
  @Prop({ default: 1 })
  sortOrder: number;
}
 
export const CourseModuleSchema = SchemaFactory.createForClass(CourseModule);
CourseModuleSchema.index({ tenantId: 1, courseId: 1 });
 
@Schema({ timestamps: true, collection: 'learning_lessons' })
export class CourseLesson extends Document {
  @Prop({ type: MongooseSchema.Types.ObjectId, required: true, index: true })
  tenantId: MongooseSchema.Types.ObjectId;
 
  @Prop({ type: MongooseSchema.Types.ObjectId, ref: 'CourseModule', required: true, index: true })
  moduleId: MongooseSchema.Types.ObjectId;
 
  @Prop({ required: true })
  title: string;
 
  @Prop({ default: 'rich_text', enum: ['rich_text', 'video', 'audio', 'pdf', 'quiz', 'live_session'] })
  lessonType: string;
 
  @Prop()
  contentBody: string; // rich text from CKEditor
 
  @Prop()
  mediaAssetId: string; // reference to Media Platform asset
 
  @Prop()
  fileUrl: string; // reference to Storage Service file url
 
  @Prop({ default: true })
  isRequired: boolean;
 
  @Prop({ default: 1 })
  sortOrder: number;
}
 
export const CourseLessonSchema = SchemaFactory.createForClass(CourseLesson);
CourseLessonSchema.index({ tenantId: 1, moduleId: 1 });