import { Connection } from "../connection/Connection"; import { EntityManager } from "./EntityManager"; import { ObjectType } from "../common/ObjectType"; import { AggregationCursor, BulkWriteOpResultObject, Code, Collection, CollectionAggregationOptions, CollectionBluckWriteOptions, CollectionInsertManyOptions, CollectionInsertOneOptions, CollectionOptions, CollStats, CommandCursor, Cursor, DeleteWriteOpResultObject, FindAndModifyWriteOpResultObject, FindOneAndReplaceOption, GeoHaystackSearchOptions, GeoNearOptions, InsertOneWriteOpResult, InsertWriteOpResult, MapReduceOptions, MongoCountPreferences, MongodbIndexOptions, OrderedBulkOperation, ParallelCollectionScanOptions, ReadPreference, ReplaceOneOptions, UnorderedBulkOperation, UpdateWriteOpResult } from "../driver/mongodb/typings"; import { ObjectLiteral } from "../common/ObjectLiteral"; import { MongoQueryRunner } from "../driver/mongodb/MongoQueryRunner"; import { FindManyOptions } from "../find-options/FindManyOptions"; import { FindOneOptions } from "../find-options/FindOneOptions"; /** * Entity manager supposed to work with any entity, automatically find its repository and call its methods, * whatever entity type are you passing. * * This implementation is used for MongoDB driver which has some specifics in its EntityManager. */ export declare class MongoEntityManager extends EntityManager { constructor(connection: Connection); /** * Gets query runner used to execute queries. */ readonly queryRunner: MongoQueryRunner; /** * Finds entities that match given find options or conditions. */ find(entityClassOrName: ObjectType | string, optionsOrConditions?: FindManyOptions | Partial): Promise; /** * Finds entities that match given find options or conditions. * Also counts all entities that match given conditions, * but ignores pagination settings (from and take options). */ findAndCount(entityClassOrName: ObjectType | string, optionsOrConditions?: FindManyOptions | Partial): Promise<[Entity[], number]>; /** * Finds entities by ids. * Optionally find options can be applied. */ findByIds(entityClassOrName: ObjectType | string, ids: any[], optionsOrConditions?: FindManyOptions | Partial): Promise; /** * Finds first entity that matches given conditions and/or find options. */ findOne(entityClassOrName: ObjectType | string, optionsOrConditions?: FindOneOptions | Partial): Promise; /** * Finds entity by given id. * Optionally find options or conditions can be applied. */ findOneById(entityClassOrName: ObjectType | string, id: any, optionsOrConditions?: FindOneOptions | Partial): Promise; /** * Creates a cursor for a query that can be used to iterate over results from MongoDB. */ createCursor(entityClassOrName: ObjectType | string, query?: ObjectLiteral): Cursor; /** * Creates a cursor for a query that can be used to iterate over results from MongoDB. * This returns modified version of cursor that transforms each result into Entity model. */ createEntityCursor(entityClassOrName: ObjectType | string, query?: ObjectLiteral): Cursor; /** * Execute an aggregation framework pipeline against the collection. */ aggregate(entityClassOrName: ObjectType | string, pipeline: ObjectLiteral[], options?: CollectionAggregationOptions): AggregationCursor; /** * Perform a bulkWrite operation without a fluent API. */ bulkWrite(entityClassOrName: ObjectType | string, operations: ObjectLiteral[], options?: CollectionBluckWriteOptions): Promise; /** * Count number of matching documents in the db to a query. */ count(entityClassOrName: ObjectType | string, query?: ObjectLiteral, options?: MongoCountPreferences): Promise; /** * Creates an index on the db and collection. */ createCollectionIndex(entityClassOrName: ObjectType | string, fieldOrSpec: string | any, options?: MongodbIndexOptions): Promise; /** * Creates multiple indexes in the collection, this method is only supported for MongoDB 2.6 or higher. * Earlier version of MongoDB will throw a command not supported error. * Index specifications are defined at http://docs.mongodb.org/manual/reference/command/createIndexes/. */ createCollectionIndexes(entityClassOrName: ObjectType | string, indexSpecs: ObjectLiteral[]): Promise; /** * Delete multiple documents on MongoDB. */ deleteMany(entityClassOrName: ObjectType | string, query: ObjectLiteral, options?: CollectionOptions): Promise; /** * Delete a document on MongoDB. */ deleteOne(entityClassOrName: ObjectType | string, query: ObjectLiteral, options?: CollectionOptions): Promise; /** * The distinct command returns returns a list of distinct values for the given key across a collection. */ distinct(entityClassOrName: ObjectType | string, key: string, query: ObjectLiteral, options?: { readPreference?: ReadPreference | string; }): Promise; /** * Drops an index from this collection. */ dropCollectionIndex(entityClassOrName: ObjectType | string, indexName: string, options?: CollectionOptions): Promise; /** * Drops all indexes from the collection. */ dropCollectionIndexes(entityClassOrName: ObjectType | string): Promise; /** * Find a document and delete it in one atomic operation, requires a write lock for the duration of the operation. */ findOneAndDelete(entityClassOrName: ObjectType | string, query: ObjectLiteral, options?: { projection?: Object; sort?: Object; maxTimeMS?: number; }): Promise; /** * Find a document and replace it in one atomic operation, requires a write lock for the duration of the operation. */ findOneAndReplace(entityClassOrName: ObjectType | string, query: ObjectLiteral, replacement: Object, options?: FindOneAndReplaceOption): Promise; /** * Find a document and update it in one atomic operation, requires a write lock for the duration of the operation. */ findOneAndUpdate(entityClassOrName: ObjectType | string, query: ObjectLiteral, update: Object, options?: FindOneAndReplaceOption): Promise; /** * Execute a geo search using a geo haystack index on a collection. */ geoHaystackSearch(entityClassOrName: ObjectType | string, x: number, y: number, options?: GeoHaystackSearchOptions): Promise; /** * Execute the geoNear command to search for items in the collection. */ geoNear(entityClassOrName: ObjectType | string, x: number, y: number, options?: GeoNearOptions): Promise; /** * Run a group command across a collection. */ group(entityClassOrName: ObjectType | string, keys: Object | Array | Function | Code, condition: Object, initial: Object, reduce: Function | Code, finalize: Function | Code, command: boolean, options?: { readPreference?: ReadPreference | string; }): Promise; /** * Retrieve all the indexes on the collection. */ collectionIndexes(entityClassOrName: ObjectType | string): Promise; /** * Retrieve all the indexes on the collection. */ collectionIndexExists(entityClassOrName: ObjectType | string, indexes: string | string[]): Promise; /** * Retrieves this collections index info. */ collectionIndexInformation(entityClassOrName: ObjectType | string, options?: { full: boolean; }): Promise; /** * Initiate an In order bulk write operation, operations will be serially executed in the order they are added, creating a new operation for each switch in types. */ initializeOrderedBulkOp(entityClassOrName: ObjectType | string, options?: CollectionOptions): OrderedBulkOperation; /** * Initiate a Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order. */ initializeUnorderedBulkOp(entityClassOrName: ObjectType | string, options?: CollectionOptions): UnorderedBulkOperation; /** * Inserts an array of documents into MongoDB. */ insertMany(entityClassOrName: ObjectType | string, docs: ObjectLiteral[], options?: CollectionInsertManyOptions): Promise; /** * Inserts a single document into MongoDB. */ insertOne(entityClassOrName: ObjectType | string, doc: ObjectLiteral, options?: CollectionInsertOneOptions): Promise; /** * Returns if the collection is a capped collection. */ isCapped(entityClassOrName: ObjectType | string): Promise; /** * Get the list of all indexes information for the collection. */ listCollectionIndexes(entityClassOrName: ObjectType | string, options?: { batchSize?: number; readPreference?: ReadPreference | string; }): CommandCursor; /** * Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection. */ mapReduce(entityClassOrName: ObjectType | string, map: Function | string, reduce: Function | string, options?: MapReduceOptions): Promise; /** * Return N number of parallel cursors for a collection allowing parallel reading of entire collection. * There are no ordering guarantees for returned results. */ parallelCollectionScan(entityClassOrName: ObjectType | string, options?: ParallelCollectionScanOptions): Promise[]>; /** * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections. */ reIndex(entityClassOrName: ObjectType | string): Promise; /** * Reindex all indexes on the collection Warning: reIndex is a blocking operation (indexes are rebuilt in the foreground) and will be slow for large collections. */ rename(entityClassOrName: ObjectType | string, newName: string, options?: { dropTarget?: boolean; }): Promise; /** * Replace a document on MongoDB. */ replaceOne(entityClassOrName: ObjectType | string, query: ObjectLiteral, doc: ObjectLiteral, options?: ReplaceOneOptions): Promise; /** * Get all the collection statistics. */ stats(entityClassOrName: ObjectType | string, options?: { scale: number; }): Promise; /** * Update multiple documents on MongoDB. */ updateMany(entityClassOrName: ObjectType | string, query: ObjectLiteral, update: ObjectLiteral, options?: { upsert?: boolean; w?: any; wtimeout?: number; j?: boolean; }): Promise; /** * Update a single document on MongoDB. */ updateOne(entityClassOrName: ObjectType | string, query: ObjectLiteral, update: ObjectLiteral, options?: ReplaceOneOptions): Promise; /** * Converts FindManyOptions to mongodb query. */ protected convertFindManyOptionsOrConditionsToMongodbQuery(optionsOrConditions: FindManyOptions | Partial | undefined): ObjectLiteral | undefined; /** * Converts FindOneOptions to mongodb query. */ protected convertFindOneOptionsOrConditionsToMongodbQuery(optionsOrConditions: FindOneOptions | Partial | undefined): ObjectLiteral | undefined; /** * Converts FindOptions into mongodb order by criteria. */ protected convertFindOptionsOrderToOrderCriteria(order: ObjectLiteral): ObjectLiteral; }