Skip to content

Commit d6eefce

Browse files
chore: update migration guide
1 parent a246179 commit d6eefce

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

etc/notes/CHANGES_5.0.0.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,25 @@ The following is a detailed collection of the changes in the major v5 release of
2020

2121
The `mapReduce` helper has been removed from the `Collection` class. The `mapReduce` operation has been
2222
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/)).
2424

2525
If the `mapReduce` command must be used, the `Db.command()` helper can be used to run the raw
2626
`mapReduce` command.
2727

2828
```typescript
29+
// using the Collection.mapReduce helper in <4.x drivers
30+
const collection = db.collection('my-collection');
31+
32+
await collection.mapReduce(
33+
function() { emit(this.user_id, 1); },
34+
function(, vals) { return 1 },
35+
{
36+
out: 'inline',
37+
readConcern: 'majority'
38+
}
39+
)
40+
41+
// manually running the command using `db.command()`
2942
const command = {
3043
mapReduce: 'my-collection',
3144
map: 'function() { emit(this.user_id, 1); }',

0 commit comments

Comments
 (0)