From b6b6b08ad5ff1ea261d2830d9d2516eda824ff80 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 9 Oct 2024 10:13:38 -0600 Subject: [PATCH 1/2] deprecate API --- src/operations/aggregate.ts | 10 +++++++++- src/operations/find.ts | 9 ++++++++- test/types/community/collection/findX.test-d.ts | 4 ++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/operations/aggregate.ts b/src/operations/aggregate.ts index a5a267ac3e4..7b67fd0422d 100644 --- a/src/operations/aggregate.ts +++ b/src/operations/aggregate.ts @@ -1,6 +1,7 @@ import type { Document } from '../bson'; import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses'; import { MongoInvalidArgumentError } from '../error'; +import { type ExplainOptions } from '../explain'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; import { maxWireVersion, type MongoDBNamespace } from '../utils'; @@ -14,7 +15,7 @@ export const DB_AGGREGATE_COLLECTION = 1 as const; const MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8; /** @public */ -export interface AggregateOptions extends CommandOperationOptions { +export interface AggregateOptions extends Omit { /** allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 \>). */ allowDiskUse?: boolean; /** The number of documents to return per batch. See [aggregation documentation](https://www.mongodb.com/docs/manual/reference/command/aggregate). */ @@ -35,6 +36,13 @@ export interface AggregateOptions extends CommandOperationOptions { let?: Document; out?: string; + + /** + * Specifies the verbosity mode for the explain output. + * @deprecated This API is deprecated in favor of `collection.aggregate().explain()` + * or `db.aggregate().explain()`. + */ + explain?: ExplainOptions['explain']; } /** @internal */ diff --git a/src/operations/find.ts b/src/operations/find.ts index a040af73bc6..55abe00a923 100644 --- a/src/operations/find.ts +++ b/src/operations/find.ts @@ -1,6 +1,7 @@ import type { Document } from '../bson'; import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses'; import { MongoInvalidArgumentError } from '../error'; +import { type ExplainOptions } from '../explain'; import { ReadConcern } from '../read_concern'; import type { Server } from '../sdam/server'; import type { ClientSession } from '../sessions'; @@ -15,7 +16,7 @@ import { Aspect, defineAspects, type Hint } from './operation'; */ // eslint-disable-next-line @typescript-eslint/no-unused-vars export interface FindOptions - extends Omit { + extends Omit { /** Sets the limit of documents returned in the query. */ limit?: number; /** Set to sort the documents coming back from the query. Array of indexes, `[['a', 1]]` etc. */ @@ -63,6 +64,12 @@ export interface FindOptions * @deprecated Starting from MongoDB 4.4 this flag is not needed and will be ignored. */ oplogReplay?: boolean; + + /** + * Specifies the verbosity mode for the explain output. + * @deprecated This API is deprecated in favor of `collection.find().explain()`. + */ + explain?: ExplainOptions['explain']; } /** @internal */ diff --git a/test/types/community/collection/findX.test-d.ts b/test/types/community/collection/findX.test-d.ts index 8720c949400..939197c3af4 100644 --- a/test/types/community/collection/findX.test-d.ts +++ b/test/types/community/collection/findX.test-d.ts @@ -388,3 +388,7 @@ expectType | null>( } ) ); + +{ + coll.find({}, { explain}); +} From ad49a882ad94d16d1461de5071e07804417c0789 Mon Sep 17 00:00:00 2001 From: Bailey Pearson Date: Wed, 9 Oct 2024 11:38:14 -0600 Subject: [PATCH 2/2] fix lint --- test/types/community/collection/findX.test-d.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/test/types/community/collection/findX.test-d.ts b/test/types/community/collection/findX.test-d.ts index 939197c3af4..8720c949400 100644 --- a/test/types/community/collection/findX.test-d.ts +++ b/test/types/community/collection/findX.test-d.ts @@ -388,7 +388,3 @@ expectType | null>( } ) ); - -{ - coll.find({}, { explain}); -}