@@ -114,7 +114,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) {
114
114
Collection2 . emit ( 'schema.attached' , this , ss , options ) ;
115
115
} ;
116
116
117
- [ Mongo . Collection , LocalCollection ] . forEach ( ( obj ) => {
117
+ for ( const obj of [ Mongo . Collection , LocalCollection ] ) {
118
118
/**
119
119
* simpleSchema
120
120
* @description function detect the correct schema by given params. If it
@@ -129,15 +129,15 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) {
129
129
obj . prototype . simpleSchema = function ( doc , options , query ) {
130
130
if ( ! this . _c2 ) return null ;
131
131
if ( this . _c2 . _simpleSchema ) return this . _c2 . _simpleSchema ;
132
-
132
+
133
133
const schemas = this . _c2 . _simpleSchemas ;
134
134
if ( schemas && schemas . length > 0 ) {
135
135
let schema , selector , target ;
136
136
// Position 0 reserved for base schema
137
137
for ( let i = 1 ; i < schemas . length ; i ++ ) {
138
138
schema = schemas [ i ] ;
139
139
selector = Object . keys ( schema . selector ) [ 0 ] ;
140
-
140
+
141
141
// We will set this to undefined because in theory, you might want to select
142
142
// on a null value.
143
143
target = undefined ;
@@ -153,7 +153,7 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) {
153
153
// on upsert/update operations
154
154
target = query [ selector ] ;
155
155
}
156
-
156
+
157
157
// we need to compare given selector with doc property or option to
158
158
// find the right schema
159
159
if ( target !== undefined && target === schema . selector [ selector ] ) {
@@ -166,12 +166,12 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) {
166
166
throw new Error ( 'No default schema' ) ;
167
167
}
168
168
}
169
-
169
+
170
170
return null ;
171
171
} ;
172
- } ) ;
172
+ }
173
173
174
- function getArgumentsAndValidationContext ( methodName , args , async ) {
174
+ function getArgumentsAndValidationContext ( methodName , args , async ) {
175
175
let options = isInsertType ( methodName ) ? args [ 1 ] : args [ 2 ] ;
176
176
177
177
// Support missing options arg
@@ -421,14 +421,12 @@ Mongo.Collection.prototype.attachSchema = function c2AttachSchema(ss, options) {
421
421
} ;
422
422
423
423
const cleanOptionsForThisOperation = { } ;
424
- [ 'autoConvert' , 'filter' , 'removeEmptyStrings' , 'removeNullsFromArrays' , 'trimStrings' ] . forEach (
425
- ( prop ) => {
426
- if ( typeof options [ prop ] === 'boolean' ) {
427
- cleanOptionsForThisOperation [ prop ] = options [ prop ] ;
428
- }
424
+ for ( const prop of [ 'autoConvert' , 'filter' , 'removeEmptyStrings' , 'removeNullsFromArrays' , 'trimStrings' ] ) {
425
+ if ( typeof options [ prop ] === 'boolean' ) {
426
+ cleanOptionsForThisOperation [ prop ] = options [ prop ] ;
429
427
}
430
- ) ;
431
-
428
+ }
429
+
432
430
// Preliminary cleaning on both client and server. On the server and for local
433
431
// collections, automatic values will also be set at this point.
434
432
schema . clean ( doc , {
0 commit comments