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: .github/pull_request_template.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,7 @@ You can do that here: https://jira.mongodb.org/projects/NODE
20
20
21
21
-[ ] Ran `npm run lint` script
22
22
-[ ] Self-review completed using the [steps outlined here](https://github.com/mongodb/node-mongodb-native/blob/HEAD/CONTRIBUTING.md#reviewer-guidelines)
23
-
-[ ] PR title follows the correct format: `<type>(NODE-xxxx)<!>: <description>`
23
+
-[ ] PR title follows the [correct format](https://www.conventionalcommits.org/en/v1.0.0/): `type(NODE-xxxx)[!]: description`
24
+
- Example: `feat(NODE-1234)!: rewriting everything in coffeescript`
Copy file name to clipboardExpand all lines: docs/upgrade-to-v5.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -187,6 +187,37 @@ EJSON.stringify({}, { strict: false }); /* migrate to */ EJSON.stringify({}, { r
187
187
* If you import BSON esmodule style `import BSON from 'bson'` then this code will crash upon loading. **TODO: This is not the case right now but it will be after NODE-4713.**
188
188
* This error will throw: `SyntaxError: The requested module 'bson' does not provide an export named 'default'`.
189
189
190
+
### `class Code` always converts `.code` to string
191
+
192
+
The `Code` class still supports the same constructor arguments as before.
193
+
It will now convert the first argument to a string before saving it to the code property, see the following:
194
+
195
+
```typescript
196
+
const myCode =newCode(function iLoveJavascript() { console.log('I love javascript') });
197
+
// myCode.code === "function iLoveJavascript() { console.log('I love javascript') }"
198
+
// typeof myCode.code === 'string'
199
+
```
200
+
201
+
### `BSON.deserialize()` only returns `Code` instances
202
+
203
+
The deserialize options: `evalFunctions`, `cacheFunctions`, and `cacheFunctionsCrc32` have been removed.
204
+
The `evalFunctions` option, when enabled, would return BSON Code typed values as eval-ed javascript functions, now it will always return Code instances.
205
+
206
+
See the following snippet for how to migrate:
207
+
```typescript
208
+
const bsonBytes =BSON.serialize(
209
+
{ iLoveJavascript: function () { console.log('I love javascript') } },
210
+
{ serializeFunctions: true } // serializeFunctions still works!
211
+
);
212
+
const result =BSON.deserialize(bsonBytes)
213
+
// result.iLoveJavascript instanceof Code
214
+
// result.iLoveJavascript.code === "function () { console.log('I love javascript') }"
0 commit comments