Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | 396x 396x 396x 517x 517x 517x 517x 288x 288x 288x 288x | import type { Document } from '../bson'; import type { Collection } from '../collection'; import { MongoAPIError } from '../error'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { AbstractOperation, type OperationOptions } from './operation'; /** @internal */ export class OptionsOperation extends AbstractOperation<Document> { override options: OperationOptions; collection: Collection; constructor(collection: Collection, options: OperationOptions) { super(options); this.options = options; this.collection = collection; } override get commandName() { return 'listCollections' as const; } override async execute(server: Server, session: ClientSession | undefined): Promise<Document> { const coll = this.collection; const [collection] = await coll.s.db .listCollections( { name: coll.collectionName }, { ...this.options, nameOnly: false, readPreference: this.readPreference, session } ) .toArray(); Iif (collection == null || collection.options == null) { throw new MongoAPIError(`collection ${coll.namespace} not found`); } return collection.options; } } |