Skip to content

Commit a473de9

Browse files
authoredOct 11, 2024··
feat(NODE-6419): deprecate explain options API for find and aggregate (#4271)
1 parent 8def42d commit a473de9

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed
 

‎src/operations/aggregate.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Document } from '../bson';
22
import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses';
33
import { MongoInvalidArgumentError } from '../error';
4+
import { type ExplainOptions } from '../explain';
45
import type { Server } from '../sdam/server';
56
import type { ClientSession } from '../sessions';
67
import { maxWireVersion, type MongoDBNamespace } from '../utils';
@@ -14,7 +15,7 @@ export const DB_AGGREGATE_COLLECTION = 1 as const;
1415
const MIN_WIRE_VERSION_$OUT_READ_CONCERN_SUPPORT = 8;
1516

1617
/** @public */
17-
export interface AggregateOptions extends CommandOperationOptions {
18+
export interface AggregateOptions extends Omit<CommandOperationOptions, 'explain'> {
1819
/** allowDiskUse lets the server know if it can use disk to store temporary results for the aggregation (requires mongodb 2.6 \>). */
1920
allowDiskUse?: boolean;
2021
/** 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 {
3536
let?: Document;
3637

3738
out?: string;
39+
40+
/**
41+
* Specifies the verbosity mode for the explain output.
42+
* @deprecated This API is deprecated in favor of `collection.aggregate().explain()`
43+
* or `db.aggregate().explain()`.
44+
*/
45+
explain?: ExplainOptions['explain'];
3846
}
3947

4048
/** @internal */

‎src/operations/find.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Document } from '../bson';
22
import { CursorResponse, ExplainedCursorResponse } from '../cmap/wire_protocol/responses';
33
import { MongoInvalidArgumentError } from '../error';
4+
import { type ExplainOptions } from '../explain';
45
import { ReadConcern } from '../read_concern';
56
import type { Server } from '../sdam/server';
67
import type { ClientSession } from '../sessions';
@@ -15,7 +16,7 @@ import { Aspect, defineAspects, type Hint } from './operation';
1516
*/
1617
// eslint-disable-next-line @typescript-eslint/no-unused-vars
1718
export interface FindOptions<TSchema extends Document = Document>
18-
extends Omit<CommandOperationOptions, 'writeConcern'> {
19+
extends Omit<CommandOperationOptions, 'writeConcern' | 'explain'> {
1920
/** Sets the limit of documents returned in the query. */
2021
limit?: number;
2122
/** Set to sort the documents coming back from the query. Array of indexes, `[['a', 1]]` etc. */
@@ -63,6 +64,12 @@ export interface FindOptions<TSchema extends Document = Document>
6364
* @deprecated Starting from MongoDB 4.4 this flag is not needed and will be ignored.
6465
*/
6566
oplogReplay?: boolean;
67+
68+
/**
69+
* Specifies the verbosity mode for the explain output.
70+
* @deprecated This API is deprecated in favor of `collection.find().explain()`.
71+
*/
72+
explain?: ExplainOptions['explain'];
6673
}
6774

6875
/** @internal */

0 commit comments

Comments
 (0)
Please sign in to comment.