import { Document, Model, Schema, model } from "mongoose"; import { CreateSchedulesDisabledParams, FindSchedulesDisabledParams, ISchedulesDisabled, ISchedulesDisabledAdapter, } from "./SchedulesDisabled.Interface"; export interface ISchedulesDisabledDocument extends Omit, Document {} export class SchedulesDisabledAdapterMongoose implements ISchedulesDisabledAdapter { schema: Schema; schedulesDisabledList: Model; constructor() { this.schema = new Schema({ employeeId: { type: Schema.Types.ObjectId, required: true, ref: "Employee" }, companyId: { type: Schema.Types.ObjectId, required: true, ref: "Companie" }, startDate: { type: Date, required: true }, endDate: { type: Date, required: true }, creationDate: { type: Date, required: true, default: Date.now }, }); this.schedulesDisabledList = model("SchedulesDisabled", this.schema); } public async create(data: CreateSchedulesDisabledParams): Promise { return await this.schedulesDisabledList.create(data); } public async delete(id: string): Promise { await this.schedulesDisabledList.deleteOne({ _id: id }).exec(); } public async find( filters: Omit ): Promise { return this.schedulesDisabledList.find(filters).exec(); } public async findOne( filters: Omit ): Promise { return this.schedulesDisabledList.findOne(filters).exec(); } }