Skip to content

Commit

Permalink
deprecate API
Browse files Browse the repository at this point in the history
  • Loading branch information
baileympearson committed Oct 9, 2024
1 parent 8785132 commit b6b6b08
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
10 changes: 9 additions & 1 deletion src/operations/aggregate.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<CommandOperationOptions, 'explain'> {
/** 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). */
Expand All @@ -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 */
Expand Down
9 changes: 8 additions & 1 deletion src/operations/find.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -15,7 +16,7 @@ import { Aspect, defineAspects, type Hint } from './operation';
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
export interface FindOptions<TSchema extends Document = Document>
extends Omit<CommandOperationOptions, 'writeConcern'> {
extends Omit<CommandOperationOptions, 'writeConcern' | 'explain'> {
/** 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. */
Expand Down Expand Up @@ -63,6 +64,12 @@ export interface FindOptions<TSchema extends Document = Document>
* @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 */
Expand Down
4 changes: 4 additions & 0 deletions test/types/community/collection/findX.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,3 +388,7 @@ expectType<WithId<{ a: number; b: string }> | null>(
}
)
);

{
coll.find({}, { explain});
}

0 comments on commit b6b6b08

Please sign in to comment.