|
1 | 1 | import { Injectable } from '@nestjs/common'; |
2 | 2 | import { InjectModel } from '@nestjs/mongoose'; |
3 | 3 | import { Identities } from './_schemas/identities.schema'; |
4 | | -import { Model } from 'mongoose'; |
| 4 | +import { Document, Model, ModifyResult, Query, QueryOptions, SaveOptions, Types, UpdateQuery } from 'mongoose'; |
5 | 5 | import { AbstractServiceSchema } from '~/_common/abstracts/abstract.service.schema'; |
| 6 | +import { AbstractSchema } from '~/_common/abstracts/schemas/abstract.schema'; |
6 | 7 |
|
7 | 8 | @Injectable() |
8 | 9 | export class IdentitiesService extends AbstractServiceSchema { |
9 | 10 | constructor(@InjectModel(Identities.name) protected _model: Model<Identities>) { |
10 | 11 | super(); |
11 | 12 | } |
| 13 | + |
| 14 | + |
| 15 | + public async create<T extends AbstractSchema | Document>(data?: any, options?: SaveOptions): Promise<Document<T, any, T>> { |
| 16 | + // noinspection UnnecessaryLocalVariableJS |
| 17 | + const created: Document<T, any, T> = await super.create(data, options); |
| 18 | + //TODO: add backends service logic here |
| 19 | + return created; |
| 20 | + } |
| 21 | + |
| 22 | + public async update<T extends AbstractSchema | Document>( |
| 23 | + _id: Types.ObjectId | any, |
| 24 | + update: UpdateQuery<T>, |
| 25 | + options?: QueryOptions<T> & { rawResult: true }, |
| 26 | + ): Promise<ModifyResult<Query<T, T, any, T>>> { |
| 27 | + // noinspection UnnecessaryLocalVariableJS |
| 28 | + const updated = await super.update(_id, update, options); |
| 29 | + //TODO: add backends service logic here |
| 30 | + return updated; |
| 31 | + } |
| 32 | + |
| 33 | + public async delete<T extends AbstractSchema | Document>(_id: Types.ObjectId | any, options?: QueryOptions<T> | null | undefined): Promise<Query<T, T, any, T>> { |
| 34 | + // noinspection UnnecessaryLocalVariableJS |
| 35 | + const deleted = await super.delete(_id, options); |
| 36 | + //TODO: add backends service logic here |
| 37 | + return deleted; |
| 38 | + } |
12 | 39 | } |
0 commit comments