import { Injectable } from "@nestjs/common"; import { InjectModel } from "@nestjs/mongoose"; import { FilterQuery, Model, Types } from "mongoose"; import { RegistrarModel } from "../schema/registrar.schema"; @Injectable() export class RegistrarDbService { constructor( @InjectModel(RegistrarModel.name) private readonly registrarModel: Model, ) {} async create( user: Partial & { password: string }, ): Promise { return this.registrarModel.create(user); } async findOne( filter: FilterQuery, ): Promise { return this.registrarModel.findOne(filter); } async findOneAndUpdate( filter: FilterQuery, update: any, ): Promise { return this.registrarModel.findOneAndUpdate(filter, update, { new: true }); } async updateOne(filter: FilterQuery, update: any) { return this.registrarModel.updateOne(filter, update); } async findById(userId: string): Promise { return this.registrarModel.findOne({ _id: new Types.ObjectId(userId) }); } }