UNPKG

@joktec/mongo

Version:

JokTec - Mongo Service

59 lines 3.46 kB
import { ConfigService, ICondition, KeyOf, LogService, OnModuleInit, Reflector } from '@joktec/core'; import { Ref } from '@typegoose/typegoose'; import { Aggregate, RefType } from 'mongoose'; import { IMongoAggregateOptions, IMongoBulkOptions, IMongoOptions, IMongoPaginationResponse, IMongoPipeline, IMongoRequest, IMongoUpdate, MongoSchema, ObjectId } from './models'; import { IMongoRepository, MongoType } from './mongo.client'; import { MongoService } from './mongo.service'; export declare abstract class MongoRepo<T extends MongoSchema, ID extends RefType = string> implements IMongoRepository<T, ID>, OnModuleInit { protected mongoService: MongoService; protected schema: typeof MongoSchema; protected conId: string; protected reflector: Reflector; protected configService: ConfigService; protected logService: LogService; protected constructor(mongoService: MongoService, schema: typeof MongoSchema, conId?: string); onModuleInit(): Promise<void>; protected get model(): MongoType<T>; protected transform(docs: any | any[]): T | T[]; qb(query?: IMongoRequest<T>, options?: IMongoOptions<T>): import("mongoose").QueryWithHelpers<(import("mongoose").FlattenMaps<{ _id: string; createdAt?: Date; updatedAt?: Date; }> & Required<{ _id: string; }> & { __v: number; })[], T, import("./helpers").QueryHelper<T>, MongoSchema, "find", import("@typegoose/typegoose/lib/types").IObjectWithTypegooseFunction>; cursor(query: IMongoRequest<T>, options?: IMongoOptions<T>): import("mongoose").Cursor<import("mongoose").FlattenMaps<{ _id: string; createdAt?: Date; updatedAt?: Date; }> & Required<{ _id: string; }> & { __v: number; }, import("mongoose").QueryOptions<T>, import("mongoose").FlattenMaps<{ _id: string; createdAt?: Date; updatedAt?: Date; }> & Required<{ _id: string; }> & { __v: number; }>; pipeline<U = T>(query?: IMongoRequest<T>, options?: IMongoAggregateOptions<U>): Aggregate<Array<U>>; paginate(query: IMongoRequest<T>, options?: IMongoOptions<T>): Promise<IMongoPaginationResponse<T>>; find(query: IMongoRequest<T>, options?: IMongoOptions<T>): Promise<T[]>; count(query: IMongoRequest<T>, options?: IMongoOptions<T>): Promise<number>; findOne(cond: ID | ObjectId | Ref<T, ID> | ICondition<T>, query?: Omit<IMongoRequest<T>, 'condition'>, options?: IMongoOptions<T>): Promise<T>; create(body: IMongoUpdate<T>, options?: IMongoOptions<T>): Promise<T>; update(cond: ID | ObjectId | Ref<T, ID> | ICondition<T>, body: IMongoUpdate<T>, options?: IMongoOptions<T>): Promise<T>; updateMany(condition: ICondition<T>, body: IMongoUpdate<T>, options?: IMongoOptions<T>): Promise<T[]>; delete(cond: ID | ObjectId | Ref<T, ID> | ICondition<T>, options?: IMongoOptions<T>): Promise<T>; deleteMany(cond: ICondition<T>, options?: IMongoOptions<T>): Promise<T[]>; restore(cond: ID | ObjectId | Ref<T, ID> | ICondition<T>, options?: IMongoOptions<T>): Promise<T>; upsert(body: IMongoUpdate<T>, onConflicts?: KeyOf<T>[], options?: IMongoOptions<T>): Promise<T>; bulkUpsert(docs: IMongoUpdate<T>[], onConflicts?: KeyOf<T>[], options?: IMongoBulkOptions): Promise<T[]>; aggregate<U = T>(pipeline: IMongoPipeline[], options?: IMongoAggregateOptions<U>): Promise<U[]>; } //# sourceMappingURL=mongo.repo.d.ts.map