import { DocumentType } from '@typegoose/typegoose/lib/types' ; import { FilterQuery , QueryOptions , UpdateQuery } from 'mongoose' ; import { BaseModel , PaginateOptions , PaginateResult } from './base_model' ; export abstract class BaseService < T > { protected model : BaseModel < DocumentType < T > > ; public async create ( data ) { return this . model . create ( data ) ; } public async deleteById ( id ) { return this . model . findByIdAndRemove ( id ) ; } public async findAll ( filter , projection ? , options ? ) { return this . model . find ( filter , projection , options ) ; } public async findAllWithPaginate ( filter , options ? ) { return this . model . paginate ( filter , options ) ; } public async findById ( id , projection ? , options ? ) { return this . model . findById ( id , projection , options ) ; } public async findOne ( filter , projection ? , options ? ) { return this . model . findOne ( filter , projection , options ) ; } public async updateById ( id , update , options ? ) { return this . model . findByIdAndUpdate ( id , update , { new : true , ... options } ) ; } }