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
+14-1Lines changed: 14 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,25 @@ The following is a detailed collection of the changes in the major v5 release of
20
20
21
21
The `mapReduce` helper has been removed from the `Collection` class. The `mapReduce` operation has been
22
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.
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
24
25
25
If the `mapReduce` command must be used, the `Db.command()` helper can be used to run the raw
26
26
`mapReduce` command.
27
27
28
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(, vals) { return1 },
35
+
{
36
+
out: 'inline',
37
+
readConcern: 'majority'
38
+
}
39
+
)
40
+
41
+
// manually running the command using `db.command()`
0 commit comments