import type Mongo from './mongo'; import type { Abortable } from 'events'; import type { Namespace } from './decorators'; import { ShellApiWithMongoClass } from './decorators'; import { asPrintable, namespaceInfo } from './enums'; import type { FindAndModifyShellOptions, FindAndModifyMethodShellOptions, RemoveShellOptions, MapReduceShellOptions, GenericCollectionSchema, GenericDatabaseSchema, GenericServerSideSchema, StringKey, SearchIndexDefinition } from './helpers'; import type { AnyBulkWriteOperation, BulkWriteOptions, CountOptions, CountDocumentsOptions, ChangeStreamOptions, CreateIndexesOptions, DeleteOptions, DistinctOptions, Document, EstimatedDocumentCountOptions, ExplainVerbosityLike, FindOneAndDeleteOptions, FindOneAndReplaceOptions, FindOneAndUpdateOptions, FindOptions, InsertOneOptions, ReplaceOptions, RunCommandOptions, UpdateOptions, DropCollectionOptions, CheckMetadataConsistencyOptions, AggregateOptions, SearchIndexDescription } from '@mongosh/service-provider-core'; import type { RunCommandCursor, Database, DatabaseWithSchema } from './index'; import { AggregationCursor, BulkWriteResult, CommandResult, Cursor, DeleteResult, Explainable, InsertManyResult, InsertOneResult, UpdateResult } from './index'; import Bulk from './bulk'; import PlanCache from './plan-cache'; import ChangeStreamCursor from './change-stream-cursor'; import type { MQLDocument, MQLQuery, MQLPipeline } from './mql-types'; export type CollectionWithSchema = StringKey> = Collection & { [k in StringKey as k extends `${N}.${infer S}` ? S : never]: Collection; }; export declare class Collection = StringKey> extends ShellApiWithMongoClass { _mongo: Mongo; _database: DatabaseWithSchema; _name: N; _cachedSampleDocs: Document[]; constructor(mongo: Mongo, database: DatabaseWithSchema | Database, name: N); [namespaceInfo](): Namespace; [asPrintable](): string; private _emitCollectionApiCall; aggregate(pipeline: MQLPipeline, options: AggregateOptions & { explain: ExplainVerbosityLike; } & Abortable): Promise; aggregate(pipeline: MQLPipeline, options?: AggregateOptions & Abortable): Promise; aggregate(...stages: MQLPipeline): Promise; bulkWrite(operations: AnyBulkWriteOperation[], options?: BulkWriteOptions): Promise; count(query?: {}, options?: CountOptions): Promise; countDocuments(query?: MQLQuery, options?: CountDocumentsOptions & Abortable): Promise; deleteMany(filter: Document, options?: DeleteOptions): Promise; deleteOne(filter: Document, options?: DeleteOptions): Promise; distinct(field: string): Promise; distinct(field: string, query: MQLQuery): Promise; distinct(field: string, query: MQLQuery, options: DistinctOptions): Promise; estimatedDocumentCount(options?: EstimatedDocumentCountOptions): Promise; find(query?: MQLQuery, projection?: Document, options?: FindOptions & { explain?: ExplainVerbosityLike; } & Abortable): Promise; findAndModify(options: FindAndModifyMethodShellOptions): Promise; findOne(query?: MQLQuery, projection?: Document, options?: FindOptions & Abortable): Promise; renameCollection(newName: string, dropTarget?: boolean): Promise; findOneAndDelete(filter: Document, options?: FindOneAndDeleteOptions): Promise; findOneAndReplace(filter: Document, replacement: Document, options?: FindAndModifyShellOptions): Promise; findOneAndUpdate(filter: Document, update: Document | Document[], options?: FindAndModifyShellOptions): Promise; insert(docs: MQLDocument | MQLDocument[], options?: BulkWriteOptions): Promise; insertMany(docs: MQLDocument[], options?: BulkWriteOptions): Promise; insertOne(doc: MQLDocument, options?: InsertOneOptions): Promise; isCapped(): Promise; remove(query: MQLQuery, options?: boolean | RemoveShellOptions): Promise; replaceOne(filter: Document, replacement: Document, options?: ReplaceOptions): Promise; update(filter: Document, update: Document, options?: UpdateOptions & { multi?: boolean; }): Promise; updateMany(filter: Document, update: Document, options?: UpdateOptions): Promise; updateOne(filter: Document, update: Document, options?: UpdateOptions & { sort?: Document; }): Promise; compactStructuredEncryptionData(): Promise; convertToCapped(size: number): Promise; _createIndexes(keyPatterns: Document[], options?: CreateIndexesOptions, commitQuorum?: number | string): Promise; createIndexes(keyPatterns: Document[], options?: CreateIndexesOptions, commitQuorum?: number | string): Promise; createIndex(keys: Document, options?: CreateIndexesOptions, commitQuorum?: number | string): Promise; ensureIndex(keys: Document, options?: CreateIndexesOptions, commitQuorum?: number | string): Promise; getIndexes(): Promise; getIndexSpecs(): Promise; getIndices(): Promise; getIndexKeys(): Promise; dropIndexes(indexes?: string | string[] | Document | Document[]): Promise; dropIndex(index: string | Document): Promise; _getSingleStorageStatValue(key: string): Promise; totalIndexSize(...args: any[]): Promise; reIndex(): Promise; getDB(): DatabaseWithSchema; getMongo(): Mongo; dataSize(): Promise; storageSize(): Promise; totalSize(): Promise; drop(options?: DropCollectionOptions): Promise; exists(): Promise; getFullName(): string; getName(): N; runCommand(commandName: string | Document, options?: RunCommandOptions): Promise; explain(verbosity?: ExplainVerbosityLike): Explainable; _getLegacyCollStats(scale: number): Promise; _aggregateAndScaleCollStats(collStats: Document[], scale: number): Promise; _getAggregatedCollStats(scale: number): Promise; stats(originalOptions?: Document | number): Promise; latencyStats(options?: Document): Promise; initializeOrderedBulkOp(): Promise; initializeUnorderedBulkOp(): Promise; getPlanCache(): PlanCache; mapReduce(map: Function | string, reduce: Function | string, optionsOrOutString: MapReduceShellOptions): Promise; validate(options?: boolean | Document): Promise; getShardVersion(): Promise; _getShardedCollectionInfo(config: DatabaseWithSchema, collStats: Document[]): Promise; getShardDistribution(): Promise>; getShardLocation(): Promise<{ shards: string[]; sharded: boolean; }>; watch(pipeline?: MQLPipeline | ChangeStreamOptions, options?: ChangeStreamOptions): Promise; hideIndex(index: string | Document): Promise; unhideIndex(index: string | Document): Promise; analyzeShardKey(key: Document, options?: Document): Promise; configureQueryAnalyzer(options: Document): Promise; checkMetadataConsistency(options?: CheckMetadataConsistencyOptions): Promise; getSearchIndexes(indexName?: string | Document, options?: Document): Promise; createSearchIndex(name: string, definition: SearchIndexDefinition): Promise; createSearchIndex(name: string, type: 'search' | 'vectorSearch', definition: SearchIndexDefinition): Promise; createSearchIndex(definition: SearchIndexDefinition, type?: 'search' | 'vectorSearch'): Promise; createSearchIndex(description: SearchIndexDescription): Promise; createSearchIndexes(specs: SearchIndexDescription[]): Promise; dropSearchIndex(indexName: string): Promise; updateSearchIndex(indexName: string, definition: Document): Promise; _getSampleDocs(): Promise; _getSampleDocsForCompletion(): Promise; } export type GetShardDistributionResult = { Totals: { data: string; docs: number; chunks: number; } & { [individualShardDistribution: `Shard ${string}`]: [ `${number} % data`, `${number} % docs in cluster`, `${string} avg obj size on shard` ]; }; [individualShardResult: `Shard ${string} at ${string}`]: { data: string; docs: number; chunks: number; 'estimated data per chunk': string; 'estimated docs per chunk': number; }; };