You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: etc/notes/CHANGES_5.0.0.md
+37
Original file line number
Diff line number
Diff line change
@@ -16,6 +16,43 @@ The following is a detailed collection of the changes in the major v5 release of
16
16
17
17
## Changes
18
18
19
+
### `Collection.mapReduce()` helper removed
20
+
21
+
The `mapReduce` helper has been removed from the `Collection` class. The `mapReduce` operation has been
22
+
deprecated in favor of the aggregation pipeline since MongoDB server version 5.0. It is recommended
23
+
to migrate code that uses `Collection.mapReduce` to use the aggregation pipeline (see [Map-Reduce to Aggregation Pipeline](https://www.mongodb.com/docs/manual/reference/map-reduce-to-aggregation-pipeline/)).
24
+
25
+
If the `mapReduce` command must be used, the `Db.command()` helper can be used to run the raw
26
+
`mapReduce` command.
27
+
28
+
```typescript
29
+
// using the Collection.mapReduce helper in <4.x drivers
30
+
const collection =db.collection('my-collection');
31
+
32
+
awaitcollection.mapReduce(
33
+
function() { emit(this.user_id, 1); },
34
+
function(k, vals) { return1 },
35
+
{
36
+
out: 'inline',
37
+
readConcern: 'majority'
38
+
}
39
+
)
40
+
41
+
// manually running the command using `db.command()`
42
+
const command = {
43
+
mapReduce: 'my-collection',
44
+
map: 'function() { emit(this.user_id, 1); }',
45
+
reduce: 'function(k,vals) { return 1; }',
46
+
out: 'inline',
47
+
readConcern: 'majority'
48
+
}
49
+
50
+
awaitdb.command(command);
51
+
```
52
+
53
+
**Note** When using the `Db.command()` helper, all `mapReduce` options should be specified
54
+
on the raw command object and should not be passed through the options object.
55
+
19
56
### `AddUserOptions.digestPassword` removed
20
57
21
58
The `digestPassword` option has been removed from the add user helper.
* 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 */
'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.'
0 commit comments