Skip to content

Commit 09f2f4e

Browse files
feat: remove fullResponse property of commandoperationoptions
1 parent 8f8ea45 commit 09f2f4e

22 files changed

+24
-1886
lines changed

src/collection.ts

Lines changed: 0 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,6 @@ import {
6868
InsertOneResult
6969
} from './operations/insert';
7070
import { IsCappedOperation } from './operations/is_capped';
71-
import {
72-
MapFunction,
73-
MapReduceOperation,
74-
MapReduceOptions,
75-
ReduceFunction
76-
} from './operations/map_reduce';
7771
import type { Hint, OperationOptions } from './operations/operation';
7872
import { OptionsOperation } from './operations/options_operation';
7973
import { RenameOperation, RenameOptions } from './operations/rename';
@@ -1524,79 +1518,6 @@ export class Collection<TSchema extends Document = Document> {
15241518
return new ChangeStream<TLocal, TChange>(this, pipeline, resolveOptions(this, options));
15251519
}
15261520

1527-
/**
1528-
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
1529-
*
1530-
* @deprecated collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.
1531-
* @param map - The mapping function.
1532-
* @param reduce - The reduce function.
1533-
* @param options - Optional settings for the command
1534-
* @param callback - An optional callback, a Promise will be returned if none is provided
1535-
*/
1536-
mapReduce<TKey = any, TValue = any>(
1537-
map: string | MapFunction<TSchema>,
1538-
reduce: string | ReduceFunction<TKey, TValue>
1539-
): Promise<Document | Document[]>;
1540-
mapReduce<TKey = any, TValue = any>(
1541-
map: string | MapFunction<TSchema>,
1542-
reduce: string | ReduceFunction<TKey, TValue>,
1543-
options: MapReduceOptions<TKey, TValue>
1544-
): Promise<Document | Document[]>;
1545-
/** @deprecated Callbacks are deprecated and will be removed in the next major version. See [mongodb-legacy](https://github.com/mongodb-js/nodejs-mongodb-legacy) for migration assistance */
1546-
mapReduce<TKey = any, TValue = any>(
1547-
map: string | MapFunction<TSchema>,
1548-
reduce: string | ReduceFunction<TKey, TValue>,
1549-
callback: Callback<Document | Document[]>
1550-
): void;
1551-
/** @deprecated Callbacks are deprecated and will be removed in the next major version. See [mongodb-legacy](https://github.com/mongodb-js/nodejs-mongodb-legacy) for migration assistance */
1552-
mapReduce<TKey = any, TValue = any>(
1553-
map: string | MapFunction<TSchema>,
1554-
reduce: string | ReduceFunction<TKey, TValue>,
1555-
options: MapReduceOptions<TKey, TValue>,
1556-
callback: Callback<Document | Document[]>
1557-
): void;
1558-
mapReduce<TKey = any, TValue = any>(
1559-
map: string | MapFunction<TSchema>,
1560-
reduce: string | ReduceFunction<TKey, TValue>,
1561-
options?: MapReduceOptions<TKey, TValue> | Callback<Document | Document[]>,
1562-
callback?: Callback<Document | Document[]>
1563-
): Promise<Document | Document[]> | void {
1564-
emitWarningOnce(
1565-
'collection.mapReduce is deprecated. Use the aggregation pipeline instead. Visit https://docs.mongodb.com/manual/reference/map-reduce-to-aggregation-pipeline for more information on how to translate map-reduce operations to the aggregation pipeline.'
1566-
);
1567-
if ('function' === typeof options) (callback = options), (options = {});
1568-
// Out must always be defined (make sure we don't break weirdly on pre 1.8+ servers)
1569-
// TODO NODE-3339: Figure out if this is still necessary given we no longer officially support pre-1.8
1570-
if (options?.out == null) {
1571-
throw new MongoInvalidArgumentError(
1572-
'Option "out" must be defined, see mongodb docs for possible values'
1573-
);
1574-
}
1575-
1576-
if ('function' === typeof map) {
1577-
map = map.toString();
1578-
}
1579-
1580-
if ('function' === typeof reduce) {
1581-
reduce = reduce.toString();
1582-
}
1583-
1584-
if ('function' === typeof options.finalize) {
1585-
options.finalize = options.finalize.toString();
1586-
}
1587-
1588-
return executeOperation(
1589-
this.s.db.s.client,
1590-
new MapReduceOperation(
1591-
this as TODO_NODE_3286,
1592-
map,
1593-
reduce,
1594-
resolveOptions(this, options) as TODO_NODE_3286
1595-
),
1596-
callback
1597-
);
1598-
}
1599-
16001521
/**
16011522
* Initiate an Out of order batch write operation. All operations will be buffered into insert/update/remove commands executed out of order.
16021523
*

src/index.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -386,12 +386,6 @@ export type {
386386
export type { InsertManyResult, InsertOneOptions, InsertOneResult } from './operations/insert';
387387
export type { CollectionInfo, ListCollectionsOptions } from './operations/list_collections';
388388
export type { ListDatabasesOptions, ListDatabasesResult } from './operations/list_databases';
389-
export type {
390-
FinalizeFunction,
391-
MapFunction,
392-
MapReduceOptions,
393-
ReduceFunction
394-
} from './operations/map_reduce';
395389
export type { AbstractOperation, Hint, OperationOptions } from './operations/operation';
396390
export type { ProfilingLevelOptions } from './operations/profiling_level';
397391
export type { RemoveUserOptions } from './operations/remove_user';

src/operations/add_user.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ export class AddUserOperation extends CommandOperation<Document> {
5757
// Error out if digestPassword set
5858
// v5 removed the digestPassword option from AddUserOptions but we still want to throw
5959
// an error when digestPassword is provided.
60-
if ('digestPassword' in options && options.digestPassword != null) {
60+
if ((options as any).digestPassword != null) {
6161
return callback(
6262
new MongoInvalidArgumentError(
6363
'Option "digestPassword" not supported via addUser, use db.command(...) instead'

src/operations/map_reduce.ts

Lines changed: 0 additions & 250 deletions
This file was deleted.

src/sessions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ export function applySession(
10071007
if (
10081008
session.supports.causalConsistency &&
10091009
session.operationTime &&
1010-
commandSupportsReadConcern(command, options)
1010+
commandSupportsReadConcern(command)
10111011
) {
10121012
command.readConcern = command.readConcern || {};
10131013
Object.assign(command.readConcern, { afterClusterTime: session.operationTime });

src/utils.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,21 +1328,8 @@ export function shuffle<T>(sequence: Iterable<T>, limit = 0): Array<T> {
13281328

13291329
// TODO: this should be codified in command construction
13301330
// @see https://github.com/mongodb/specifications/blob/master/source/read-write-concern/read-write-concern.rst#read-concern
1331-
export function commandSupportsReadConcern(command: Document, options?: Document): boolean {
1332-
if (command.aggregate || command.count || command.distinct || command.find || command.geoNear) {
1333-
return true;
1334-
}
1335-
1336-
if (
1337-
command.mapReduce &&
1338-
options &&
1339-
options.out &&
1340-
(options.out.inline === 1 || options.out === 'inline')
1341-
) {
1342-
return true;
1343-
}
1344-
1345-
return false;
1331+
export function commandSupportsReadConcern(command: Document): boolean {
1332+
return command.aggregate || command.count || command.distinct || command.find || command.geoNear;
13461333
}
13471334

13481335
/** A utility function to get the instance of mongodb-client-encryption, if it exists. */

0 commit comments

Comments
 (0)