import { Injectable } from "@nestjs/common"; import { InjectModel } from "@nestjs/mongoose"; import { FilterQuery, Model, Types } from "mongoose"; import { ClaimRequiredDocument } from "src/claim-request-management/entites/schema/claim-required-document.schema"; @Injectable() export class ClaimRequiredDocumentDbService { constructor( @InjectModel(ClaimRequiredDocument.name) private readonly model: Model, ) {} async create(document: Partial): Promise { return await this.model.create(document); } async findOne( filter: FilterQuery, ): Promise { return await this.model.findOne(filter); } async findAll( filter: FilterQuery, ): Promise { return await this.model.find(filter); } async findById(id: string): Promise { return this.model.findById(id).lean(); } async findByClaimId(claimId: string): Promise { return this.model.find({ claimId: new Types.ObjectId(claimId) }); } async delete(id: string): Promise { await this.model.findByIdAndDelete(id); } }