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: docs/upgrade-to-v5.md
+6-2Lines changed: 6 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@ The following is a detailed collection of the changes in the major v5 release of
29
29
30
30
For those that use the BSON library on Node.js, there is no change - the BSON APIs will still return and accept instances of Node.js `Buffer`. Since we no longer depend on the `Buffer` web shim for compatibility with browsers, in non-Node.js environments a `Uint8Array` will be returned instead.
31
31
32
-
This allows the BSON library to be more platform independent while keeping its behavior consistent cross platform.
32
+
This allows the BSON library to be more platform independent while keeping its behavior consistent cross platform.
33
33
34
34
#### APIs impacted
35
35
@@ -73,6 +73,10 @@ We have set our TypeScript compilation target to `es2020` which aligns with our
73
73
74
74
> This will preserve newer ECMAScript 2020 features like optional chaining, nullish coalescing, export \* as ns, and dynamic import(...) syntax. It also means bigint literals now have a stable target below esnext.
75
75
76
+
#### `class` syntax
77
+
78
+
Previously, our compilation target was set such that each BSON `class` became a function in the shipped code, allowing callers to omit the `new` keyword. Because of the `"target"` upgrade, the library now ships javascript `class` syntax which requires callers to use the `new` keyword.
79
+
76
80
### `serializeFunctions` bug fix
77
81
78
82
If `serializeFunctions` was enabled and the functions being serialized had a name that is outside of [Controls and Basic Latin](https://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF) character ranges (a.k.a utf8 bytes: `0x00-0x7F`) they would be incorrectly serialized.
@@ -83,7 +87,7 @@ This library no longer polyfills [ES Map](https://developer.mozilla.org/en-US/do
83
87
84
88
### `Decimal128``toObject()` mapper support removed
85
89
86
-
`Decimal128` can no longer have a `toObject()` method added on to its prototype for mapping to a custom value. This feature was undocumented and inconsistent with the rest of our BSON types.
90
+
`Decimal128` can no longer have a `toObject()` method added on to its prototype for mapping to a custom value. This feature was undocumented and inconsistent with the rest of our BSON types.
87
91
88
92
At this time there is no direct migration. Cursors in the driver support transformations via `.map`, otherwise the `Decimal128` instances will require manual transformation. There is a plan to provide a better mechanism for consistently transforming BSON values tracked in [NODE-4680](https://jira.mongodb.org/browse/NODE-4680). Please feel free to add a vote or comment with a use case to help us land the feature in the most useful form.
0 commit comments