This commit is contained in:
mahyargdz
2025-09-14 15:15:03 +03:30
commit be82059172
534 changed files with 51310 additions and 0 deletions
@@ -0,0 +1,10 @@
import { Schema } from "mongoose";
export interface ILearning {
title: string;
description: string;
videoUrl: string;
cover: string;
category: Schema.Types.ObjectId;
deleted: boolean;
}
@@ -0,0 +1,4 @@
export interface ILearningCategory {
title: string;
deleted: boolean;
}
@@ -0,0 +1,7 @@
import { Schema } from "mongoose";
export interface ILearningProgress {
sellerId: Schema.Types.ObjectId;
videoId: Schema.Types.ObjectId;
watchedAt?: Date;
}
@@ -0,0 +1,23 @@
import { Schema, model } from "mongoose";
import { ILearning } from "./Abstractions/ILearning";
const LearningSchema = new Schema<ILearning>(
{
title: { type: String, required: true },
description: { type: String, required: true },
videoUrl: { type: String, required: true },
cover: { type: String, required: true },
category: { type: Schema.Types.ObjectId, ref: "LearningCategory", required: true },
deleted: { type: Boolean, default: false },
},
{
timestamps: true,
toJSON: { versionKey: false, virtuals: true },
id: false,
},
);
const LearningModel = model<ILearning>("Learning", LearningSchema);
export { LearningModel };
@@ -0,0 +1,19 @@
import { Schema, model } from "mongoose";
import { ILearningCategory } from "./Abstractions/ILearningCategory";
const LearningCategorySchema = new Schema<ILearningCategory>(
{
title: { type: String, required: true, unique: true },
deleted: { type: Boolean, default: false },
},
{
timestamps: true,
toJSON: { versionKey: false, virtuals: true },
id: false,
},
);
const LearningCategoryModel = model<ILearningCategory>("LearningCategory", LearningCategorySchema);
export { LearningCategoryModel };
@@ -0,0 +1,23 @@
import { Schema, model } from "mongoose";
import { ILearningProgress } from "./Abstractions/ILearningProgress";
const LearningProgressSchema = new Schema<ILearningProgress>(
{
sellerId: { type: Schema.Types.ObjectId, ref: "Seller", required: true },
videoId: { type: Schema.Types.ObjectId, ref: "Learning", required: true },
watchedAt: { type: Date },
},
{
timestamps: true,
toJSON: { versionKey: false, virtuals: true },
id: false,
},
);
// Defining a unique compound index for sellerId and videoId
LearningProgressSchema.index({ sellerId: 1, videoId: 1 }, { unique: true });
const LearningProgressModel = model<ILearningProgress>("LearningProgress", LearningProgressSchema);
export { LearningProgressModel };