File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 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');
1010const normalizedFunctionString = require ( './utils' ) . normalizedFunctionString ;
1111
1212const regexp = / \x00 / ; // eslint-disable-line no-control-regex
13+ const ignoreKeys = new Set ( [ '$db' , '$ref' , '$id' , '$clusterTime' ] ) ;
1314
1415// To ensure that 0.4 of node works correctly
1516const isDate = function isDate ( d ) {
@@ -785,7 +786,7 @@ function serializeInto(
785786 const type = typeof value ;
786787
787788 // Check the key and throw error if it's illegal
788- if ( key !== '$db' && key !== '$ref' && key !== '$id' ) {
789+ if ( ! ignoreKeys . has ( key ) ) {
789790 if ( key . match ( regexp ) != null ) {
790791 // The BSON spec doesn't allow keys with null bytes because keys are
791792 // null-terminated.
@@ -885,7 +886,7 @@ function serializeInto(
885886 const type = typeof value ;
886887
887888 // Check the key and throw error if it's illegal
888- if ( key !== '$db' && key !== '$ref' && key !== '$id' ) {
889+ if ( ! ignoreKeys . has ( key ) ) {
889890 if ( key . match ( regexp ) != null ) {
890891 // The BSON spec doesn't allow keys with null bytes because keys are
891892 // null-terminated.
You can’t perform that action at this time.
0 commit comments