diff --git a/src/collection.ts b/src/collection.ts index 3fe20d6b41..471fa3e713 100644 --- a/src/collection.ts +++ b/src/collection.ts @@ -1415,6 +1415,7 @@ export class Collection { /** * 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 @@ -1446,6 +1447,9 @@ export class Collection { options?: MapReduceOptions | Callback, callback?: Callback ): Promise | 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 diff --git a/test/types/mongodb.test-d.ts b/test/types/mongodb.test-d.ts index 204c5ca934..c03e942de1 100644 --- a/test/types/mongodb.test-d.ts +++ b/test/types/mongodb.test-d.ts @@ -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);