2850 lines
57 KiB
JavaScript
2850 lines
57 KiB
JavaScript
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const db = require('../models');
|
|
const Users = db.users;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Courses = db.courses;
|
|
|
|
const Lessons = db.lessons;
|
|
|
|
const Enrollments = db.enrollments;
|
|
|
|
const ProgressRecords = db.progress_records;
|
|
|
|
const CourseMaterials = db.course_materials;
|
|
|
|
const Reviews = db.reviews;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const CoursesData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Introduction to Data Science",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Foundational data science concepts, Python, and statistics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "Data Science",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "beginner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 49.99,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-05-01T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Advanced Machine Learning",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Deep dive into neural networks and model optimization",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "Data Science",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "beginner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 199.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": false,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-03-15T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-07-15T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Modern Frontend Development",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "React, state management, and modern build tooling",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "Web Development",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "beginner",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 129.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-01-10T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-04-10T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "UI Design Fundamentals",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Design principles, color theory, and prototyping",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "Design",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "advanced",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 79.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-02-20T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-03-20T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Product Analytics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"description": "Measuring product impact and user behavior",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"category": "Product",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"level": "advanced",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"price": 89.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"published": true,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"start_date": new Date('2026-04-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"end_date": new Date('2026-06-30T17:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "images" field
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const LessonsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Python Basics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Variables, control flow, and functions",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 45,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.courseflow.io/python-basics.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_from": new Date('2026-02-01T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_to": new Date('2026-05-01T17:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Exploratory Data Analysis",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Pandas, visualization, and data cleaning techniques",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 60,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.courseflow.io/eda.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 2,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_from": new Date('2026-02-05T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_to": new Date('2026-05-01T17:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Neural Network Basics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Perceptrons, backpropagation, and training loops",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 75,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.courseflow.io/nn-basics.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_from": new Date('2026-03-15T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_to": new Date('2026-07-15T17:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "State Management with Redux",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Redux patterns, middleware, and best practices",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 50,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.courseflow.io/redux.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_from": new Date('2026-01-12T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_to": new Date('2026-04-10T17:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"title": "Design Systems Overview",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"content": "Tokens, components, and scalable UI systems",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_minutes": 40,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"video_url": "https://videos.courseflow.io/design-systems.mp4",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"order": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_from": new Date('2026-02-20T09:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"available_to": new Date('2026-03-20T17:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const EnrollmentsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "ENR-2026-0001",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-02-02T10:15:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "canceled",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 12.5,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "ENR-2026-0002",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-01-15T08:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 40.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "ENR-2026-0003",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-01-20T14:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 100.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "ENR-2026-0004",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-02-10T11:45:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "pending",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 0.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"reference": "ENR-2026-0005",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"enrolled_on": new Date('2026-02-21T09:10:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "active",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"progress_percent": 25.0,
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ProgressRecordsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"summary": "Completed Python Basics lesson",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date('2026-02-03T12:00:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 88.5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_seconds": 2700,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Watched video and completed quiz",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"summary": "Started Exploratory Data Analysis",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date(''),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_seconds": 900,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Working through examples",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"summary": "Finished Redux lesson",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "completed",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date('2026-02-01T15:30:00Z'),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 92.0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_seconds": 3000,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Implemented sample app",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"summary": "Viewed Design Systems overview",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date(''),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_seconds": 1200,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "Taking notes on component patterns",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
"summary": "Started Neural Network Basics",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"status": "in_progress",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"completed_on": new Date(''),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"score": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"duration_seconds": 0,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"notes": "",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const CourseMaterialsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Syllabus and Schedule",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "code",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "enrolled_only",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Frontend Starter Kit",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "other",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "public",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "UI Patterns Slide Deck",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "slides",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "enrolled_only",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "ML Reference Notebook",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "pdf",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "public",
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"title": "Analytics Cheat Sheet",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "files" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"material_type": "slides",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"visibility": "public",
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
const ReviewsData = [
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"comment": "Great introduction and clear exercises",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reviewed_on": new Date('2026-03-01T10:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"comment": "Very practical and up to date",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reviewed_on": new Date('2026-02-25T14:30:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": 4,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"comment": "Good design examples and templates",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reviewed_on": new Date('2026-03-05T09:20:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": 5,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"comment": "Solid fundamentals and well explained",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reviewed_on": new Date('2026-03-02T16:45:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// type code here for "relation_one" field
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"rating": 3,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"comment": "Useful but could use more hands on labs",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"reviewed_on": new Date('2026-05-10T12:00:00Z'),
|
|
|
|
|
|
|
|
},
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCoursWithInstructor() {
|
|
|
|
const relatedInstructor0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours0 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Cours0?.setInstructor)
|
|
{
|
|
await
|
|
Cours0.
|
|
setInstructor(relatedInstructor0);
|
|
}
|
|
|
|
const relatedInstructor1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours1 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Cours1?.setInstructor)
|
|
{
|
|
await
|
|
Cours1.
|
|
setInstructor(relatedInstructor1);
|
|
}
|
|
|
|
const relatedInstructor2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours2 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Cours2?.setInstructor)
|
|
{
|
|
await
|
|
Cours2.
|
|
setInstructor(relatedInstructor2);
|
|
}
|
|
|
|
const relatedInstructor3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours3 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Cours3?.setInstructor)
|
|
{
|
|
await
|
|
Cours3.
|
|
setInstructor(relatedInstructor3);
|
|
}
|
|
|
|
const relatedInstructor4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Cours4 = await Courses.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Cours4?.setInstructor)
|
|
{
|
|
await
|
|
Cours4.
|
|
setInstructor(relatedInstructor4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateLessonWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson0 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Lesson0?.setCourse)
|
|
{
|
|
await
|
|
Lesson0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson1 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Lesson1?.setCourse)
|
|
{
|
|
await
|
|
Lesson1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson2 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Lesson2?.setCourse)
|
|
{
|
|
await
|
|
Lesson2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson3 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Lesson3?.setCourse)
|
|
{
|
|
await
|
|
Lesson3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
const relatedCourse4 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Lesson4 = await Lessons.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Lesson4?.setCourse)
|
|
{
|
|
await
|
|
Lesson4.
|
|
setCourse(relatedCourse4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateEnrollmentWithStudent() {
|
|
|
|
const relatedStudent0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment0 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Enrollment0?.setStudent)
|
|
{
|
|
await
|
|
Enrollment0.
|
|
setStudent(relatedStudent0);
|
|
}
|
|
|
|
const relatedStudent1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment1 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Enrollment1?.setStudent)
|
|
{
|
|
await
|
|
Enrollment1.
|
|
setStudent(relatedStudent1);
|
|
}
|
|
|
|
const relatedStudent2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment2 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Enrollment2?.setStudent)
|
|
{
|
|
await
|
|
Enrollment2.
|
|
setStudent(relatedStudent2);
|
|
}
|
|
|
|
const relatedStudent3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment3 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Enrollment3?.setStudent)
|
|
{
|
|
await
|
|
Enrollment3.
|
|
setStudent(relatedStudent3);
|
|
}
|
|
|
|
const relatedStudent4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Enrollment4 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Enrollment4?.setStudent)
|
|
{
|
|
await
|
|
Enrollment4.
|
|
setStudent(relatedStudent4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateEnrollmentWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment0 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Enrollment0?.setCourse)
|
|
{
|
|
await
|
|
Enrollment0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment1 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Enrollment1?.setCourse)
|
|
{
|
|
await
|
|
Enrollment1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment2 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Enrollment2?.setCourse)
|
|
{
|
|
await
|
|
Enrollment2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment3 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Enrollment3?.setCourse)
|
|
{
|
|
await
|
|
Enrollment3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
const relatedCourse4 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Enrollment4 = await Enrollments.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Enrollment4?.setCourse)
|
|
{
|
|
await
|
|
Enrollment4.
|
|
setCourse(relatedCourse4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateProgressRecordWithEnrollment() {
|
|
|
|
const relatedEnrollment0 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressRecord0 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProgressRecord0?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressRecord0.
|
|
setEnrollment(relatedEnrollment0);
|
|
}
|
|
|
|
const relatedEnrollment1 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressRecord1 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProgressRecord1?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressRecord1.
|
|
setEnrollment(relatedEnrollment1);
|
|
}
|
|
|
|
const relatedEnrollment2 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressRecord2 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProgressRecord2?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressRecord2.
|
|
setEnrollment(relatedEnrollment2);
|
|
}
|
|
|
|
const relatedEnrollment3 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressRecord3 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ProgressRecord3?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressRecord3.
|
|
setEnrollment(relatedEnrollment3);
|
|
}
|
|
|
|
const relatedEnrollment4 = await Enrollments.findOne({
|
|
offset: Math.floor(Math.random() * (await Enrollments.count())),
|
|
});
|
|
const ProgressRecord4 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (ProgressRecord4?.setEnrollment)
|
|
{
|
|
await
|
|
ProgressRecord4.
|
|
setEnrollment(relatedEnrollment4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProgressRecordWithLesson() {
|
|
|
|
const relatedLesson0 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressRecord0 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProgressRecord0?.setLesson)
|
|
{
|
|
await
|
|
ProgressRecord0.
|
|
setLesson(relatedLesson0);
|
|
}
|
|
|
|
const relatedLesson1 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressRecord1 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProgressRecord1?.setLesson)
|
|
{
|
|
await
|
|
ProgressRecord1.
|
|
setLesson(relatedLesson1);
|
|
}
|
|
|
|
const relatedLesson2 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressRecord2 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProgressRecord2?.setLesson)
|
|
{
|
|
await
|
|
ProgressRecord2.
|
|
setLesson(relatedLesson2);
|
|
}
|
|
|
|
const relatedLesson3 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressRecord3 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ProgressRecord3?.setLesson)
|
|
{
|
|
await
|
|
ProgressRecord3.
|
|
setLesson(relatedLesson3);
|
|
}
|
|
|
|
const relatedLesson4 = await Lessons.findOne({
|
|
offset: Math.floor(Math.random() * (await Lessons.count())),
|
|
});
|
|
const ProgressRecord4 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (ProgressRecord4?.setLesson)
|
|
{
|
|
await
|
|
ProgressRecord4.
|
|
setLesson(relatedLesson4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateProgressRecordWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProgressRecord0 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (ProgressRecord0?.setUser)
|
|
{
|
|
await
|
|
ProgressRecord0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProgressRecord1 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (ProgressRecord1?.setUser)
|
|
{
|
|
await
|
|
ProgressRecord1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProgressRecord2 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (ProgressRecord2?.setUser)
|
|
{
|
|
await
|
|
ProgressRecord2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProgressRecord3 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (ProgressRecord3?.setUser)
|
|
{
|
|
await
|
|
ProgressRecord3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const ProgressRecord4 = await ProgressRecords.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (ProgressRecord4?.setUser)
|
|
{
|
|
await
|
|
ProgressRecord4.
|
|
setUser(relatedUser4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateCourseMaterialWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const CourseMaterial0 = await CourseMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (CourseMaterial0?.setCourse)
|
|
{
|
|
await
|
|
CourseMaterial0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const CourseMaterial1 = await CourseMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (CourseMaterial1?.setCourse)
|
|
{
|
|
await
|
|
CourseMaterial1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const CourseMaterial2 = await CourseMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (CourseMaterial2?.setCourse)
|
|
{
|
|
await
|
|
CourseMaterial2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const CourseMaterial3 = await CourseMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (CourseMaterial3?.setCourse)
|
|
{
|
|
await
|
|
CourseMaterial3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
const relatedCourse4 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const CourseMaterial4 = await CourseMaterials.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (CourseMaterial4?.setCourse)
|
|
{
|
|
await
|
|
CourseMaterial4.
|
|
setCourse(relatedCourse4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function associateReviewWithCourse() {
|
|
|
|
const relatedCourse0 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Review0 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Review0?.setCourse)
|
|
{
|
|
await
|
|
Review0.
|
|
setCourse(relatedCourse0);
|
|
}
|
|
|
|
const relatedCourse1 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Review1 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Review1?.setCourse)
|
|
{
|
|
await
|
|
Review1.
|
|
setCourse(relatedCourse1);
|
|
}
|
|
|
|
const relatedCourse2 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Review2 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Review2?.setCourse)
|
|
{
|
|
await
|
|
Review2.
|
|
setCourse(relatedCourse2);
|
|
}
|
|
|
|
const relatedCourse3 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Review3 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Review3?.setCourse)
|
|
{
|
|
await
|
|
Review3.
|
|
setCourse(relatedCourse3);
|
|
}
|
|
|
|
const relatedCourse4 = await Courses.findOne({
|
|
offset: Math.floor(Math.random() * (await Courses.count())),
|
|
});
|
|
const Review4 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Review4?.setCourse)
|
|
{
|
|
await
|
|
Review4.
|
|
setCourse(relatedCourse4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async function associateReviewWithUser() {
|
|
|
|
const relatedUser0 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Review0 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 0
|
|
});
|
|
if (Review0?.setUser)
|
|
{
|
|
await
|
|
Review0.
|
|
setUser(relatedUser0);
|
|
}
|
|
|
|
const relatedUser1 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Review1 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 1
|
|
});
|
|
if (Review1?.setUser)
|
|
{
|
|
await
|
|
Review1.
|
|
setUser(relatedUser1);
|
|
}
|
|
|
|
const relatedUser2 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Review2 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 2
|
|
});
|
|
if (Review2?.setUser)
|
|
{
|
|
await
|
|
Review2.
|
|
setUser(relatedUser2);
|
|
}
|
|
|
|
const relatedUser3 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Review3 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 3
|
|
});
|
|
if (Review3?.setUser)
|
|
{
|
|
await
|
|
Review3.
|
|
setUser(relatedUser3);
|
|
}
|
|
|
|
const relatedUser4 = await Users.findOne({
|
|
offset: Math.floor(Math.random() * (await Users.count())),
|
|
});
|
|
const Review4 = await Reviews.findOne({
|
|
order: [['id', 'ASC']],
|
|
offset: 4
|
|
});
|
|
if (Review4?.setUser)
|
|
{
|
|
await
|
|
Review4.
|
|
setUser(relatedUser4);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = {
|
|
up: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Courses.bulkCreate(CoursesData);
|
|
|
|
|
|
|
|
|
|
await Lessons.bulkCreate(LessonsData);
|
|
|
|
|
|
|
|
|
|
await Enrollments.bulkCreate(EnrollmentsData);
|
|
|
|
|
|
|
|
|
|
await ProgressRecords.bulkCreate(ProgressRecordsData);
|
|
|
|
|
|
|
|
|
|
await CourseMaterials.bulkCreate(CourseMaterialsData);
|
|
|
|
|
|
|
|
|
|
await Reviews.bulkCreate(ReviewsData);
|
|
|
|
|
|
await Promise.all([
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Similar logic for "relation_many"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCoursWithInstructor(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateLessonWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithStudent(),
|
|
|
|
|
|
|
|
|
|
await associateEnrollmentWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateProgressRecordWithEnrollment(),
|
|
|
|
|
|
|
|
|
|
await associateProgressRecordWithLesson(),
|
|
|
|
|
|
|
|
|
|
await associateProgressRecordWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateCourseMaterialWithCourse(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await associateReviewWithCourse(),
|
|
|
|
|
|
|
|
|
|
await associateReviewWithUser(),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
]);
|
|
|
|
},
|
|
|
|
down: async (queryInterface, Sequelize) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await queryInterface.bulkDelete('courses', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('lessons', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('enrollments', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('progress_records', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('course_materials', null, {});
|
|
|
|
|
|
await queryInterface.bulkDelete('reviews', null, {});
|
|
|
|
|
|
},
|
|
}; |