File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ const constants = require('../constants');
10
10
const normalizedFunctionString = require ( './utils' ) . normalizedFunctionString ;
11
11
12
12
const regexp = / \x00 / ; // eslint-disable-line no-control-regex
13
+ const ignoreKeys = new Set ( [ '$db' , '$ref' , '$id' , '$clusterTime' ] ) ;
13
14
14
15
// To ensure that 0.4 of node works correctly
15
16
const isDate = function isDate ( d ) {
@@ -785,7 +786,7 @@ function serializeInto(
785
786
const type = typeof value ;
786
787
787
788
// Check the key and throw error if it's illegal
788
- if ( key !== '$db' && key !== '$ref' && key !== '$id' ) {
789
+ if ( ! ignoreKeys . has ( key ) ) {
789
790
if ( key . match ( regexp ) != null ) {
790
791
// The BSON spec doesn't allow keys with null bytes because keys are
791
792
// null-terminated.
@@ -885,7 +886,7 @@ function serializeInto(
885
886
const type = typeof value ;
886
887
887
888
// Check the key and throw error if it's illegal
888
- if ( key !== '$db' && key !== '$ref' && key !== '$id' ) {
889
+ if ( ! ignoreKeys . has ( key ) ) {
889
890
if ( key . match ( regexp ) != null ) {
890
891
// The BSON spec doesn't allow keys with null bytes because keys are
891
892
// null-terminated.
You can’t perform that action at this time.
0 commit comments