Skip to content

Commit

Permalink
feat(NODE-3446): deprecate mapReduce command (#3036)
Browse files Browse the repository at this point in the history
  • Loading branch information
ljhaywar committed Nov 11, 2021
1 parent d5ae78e commit b6c73bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/collection.ts
Expand Up @@ -1415,6 +1415,7 @@ export class Collection<TSchema extends Document = Document> {
/**
* Run Map Reduce across a collection. Be aware that the inline option for out will return an array of results not a collection.
*
* @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.
* @param map - The mapping function.
* @param reduce - The reduce function.
* @param options - Optional settings for the command
Expand Down Expand Up @@ -1446,6 +1447,9 @@ export class Collection<TSchema extends Document = Document> {
options?: MapReduceOptions<TKey, TValue> | Callback<Document | Document[]>,
callback?: Callback<Document | Document[]>
): Promise<Document | Document[]> | void {
emitWarningOnce(
'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.'
);
if ('function' === typeof options) (callback = options), (options = {});
// Out must always be defined (make sure we don't break weirdly on pre 1.8+ servers)
// TODO NODE-3339: Figure out if this is still necessary given we no longer officially support pre-1.8
Expand Down
1 change: 1 addition & 0 deletions test/types/mongodb.test-d.ts
Expand Up @@ -14,6 +14,7 @@ expectDeprecated(Collection.prototype.insert);
expectDeprecated(Collection.prototype.update);
expectDeprecated(Collection.prototype.remove);
expectDeprecated(Collection.prototype.count);
expectDeprecated(Collection.prototype.mapReduce);
expectDeprecated(AggregationCursor.prototype.geoNear);
expectDeprecated(Topology.prototype.unref);
expectDeprecated(Db.prototype.unref);
Expand Down

0 comments on commit b6c73bf

Please sign in to comment.