Skip to content

Commit b6c73bf

Browse files
authored
feat(NODE-3446): deprecate mapReduce command (#3036)
1 parent d5ae78e commit b6c73bf

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

src/collection.ts

+4
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,7 @@ export class Collection<TSchema extends Document = Document> {
14151415
/**
14161416
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
14171417
*
1418+
* @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.
14181419
* @param map - The mapping function.
14191420
* @param reduce - The reduce function.
14201421
* @param options - Optional settings for the command
@@ -1446,6 +1447,9 @@ export class Collection<TSchema extends Document = Document> {
14461447
options?: MapReduceOptions<TKey, TValue> | Callback<Document | Document[]>,
14471448
callback?: Callback<Document | Document[]>
14481449
): Promise<Document | Document[]> | void {
1450+
emitWarningOnce(
1451+
'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.'
1452+
);
14491453
if ('function' === typeof options) (callback = options), (options = {});
14501454
// Out must always be defined (make sure we don't break weirdly on pre 1.8+ servers)
14511455
// TODO NODE-3339: Figure out if this is still necessary given we no longer officially support pre-1.8

test/types/mongodb.test-d.ts

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ expectDeprecated(Collection.prototype.insert);
1414
expectDeprecated(Collection.prototype.update);
1515
expectDeprecated(Collection.prototype.remove);
1616
expectDeprecated(Collection.prototype.count);
17+
expectDeprecated(Collection.prototype.mapReduce);
1718
expectDeprecated(AggregationCursor.prototype.geoNear);
1819
expectDeprecated(Topology.prototype.unref);
1920
expectDeprecated(Db.prototype.unref);

0 commit comments

Comments
 (0)