import { Injectable } from '@nestjs/common'; import { CommonArea, CommonAreaDocument } from 'src/schemas/common_area.schema'; import { InjectModel } from '@nestjs/mongoose'; import { Model } from 'mongoose'; @Injectable() export class CommonAreasService { constructor( @InjectModel(CommonArea.name) private readonly commonAreaModel: Model, ) {} async create(commonArea: CommonAreaDocument): Promise { return this.commonAreaModel.create(commonArea); } async findAll(): Promise { return this.commonAreaModel .find() .setOptions({ sanitizeFilter: true }) .exec(); } findOne(id: string): Promise { return this.commonAreaModel.findOne({ _id: id }).exec(); } update(id: string, commonArea: CommonAreaDocument) { return this.commonAreaModel.findOneAndUpdate({ _id: id }, commonArea, { new: true, }); } async remove(id: string) { return this.commonAreaModel.findByIdAndRemove({ _id: id }).exec(); } }