@@ -180,14 +180,15 @@ function getArgumentsAndValidationContext(methodName, args, async) {
180
180
}
181
181
182
182
let validationContext = { } ;
183
+ let validatedArgs = args ;
183
184
if ( this . _c2 && options . bypassCollection2 !== true ) {
184
185
let userId = null ;
185
186
try {
186
187
// https://github.com/aldeed/meteor-collection2/issues/175
187
188
userId = Meteor . userId ( ) ;
188
189
} catch ( err ) { }
189
190
190
- [ args , validationContext ] = doValidate (
191
+ [ validatedArgs , validationContext ] = doValidate (
191
192
this ,
192
193
methodName ,
193
194
args ,
@@ -197,17 +198,17 @@ function getArgumentsAndValidationContext(methodName, args, async) {
197
198
async
198
199
) ;
199
200
200
- if ( ! args ) {
201
+ if ( ! validatedArgs ) {
201
202
// doValidate already called the callback or threw the error, so we're done.
202
203
// But insert should always return an ID to match core behavior.
203
204
return isInsertType ( methodName ) ? this . _makeNewID ( ) : undefined ;
204
205
}
205
206
} else {
206
207
// We still need to adjust args because insert does not take options
207
- if ( isInsertType ( methodName ) && typeof args [ 1 ] !== 'function' ) args . splice ( 1 , 1 ) ;
208
+ if ( isInsertType ( methodName ) && typeof validatedArgs [ 1 ] !== 'function' ) validatedArgs . splice ( 1 , 1 ) ;
208
209
}
209
210
210
- return [ args , validationContext ] ;
211
+ return [ validatedArgs , validationContext ] ;
211
212
}
212
213
213
214
function _methodMutation ( async , methodName ) {
@@ -217,13 +218,13 @@ function getArgumentsAndValidationContext(methodName, args, async) {
217
218
218
219
if ( ! _super ) return ;
219
220
Mongo . Collection . prototype [ methodName ] = function ( ...args ) {
220
- [ args , validationContext ] = getArgumentsAndValidationContext . call ( this , methodName , args , async ) ;
221
+ const [ validatedArgs , validationContext ] = getArgumentsAndValidationContext . call ( this , methodName , args , async ) ;
221
222
222
223
if ( async && ! Meteor . isFibersDisabled ) {
223
224
try {
224
225
this [ methodName . replace ( 'Async' , '' ) ] . isCalledFromAsync = true ;
225
226
_super . isCalledFromAsync = true ;
226
- return Promise . resolve ( _super . apply ( this , args ) ) ;
227
+ return Promise . resolve ( _super . apply ( this , validatedArgs ) ) ;
227
228
} catch ( err ) {
228
229
if ( this . _c2 ) {
229
230
const addValidationErrorsPropName =
@@ -239,18 +240,18 @@ function getArgumentsAndValidationContext(methodName, args, async) {
239
240
}
240
241
}
241
242
} else {
242
- return _super . apply ( this , args ) ;
243
+ return _super . apply ( this , validatedArgs ) ;
243
244
}
244
245
} ;
245
246
}
246
247
247
248
function _methodMutationAsync ( methodName ) {
248
249
const _super = Mongo . Collection . prototype [ methodName ] ;
249
250
Mongo . Collection . prototype [ methodName ] = async function ( ...args ) {
250
- [ args , validationContext ] = getArgumentsAndValidationContext . call ( this , methodName , args , true ) ;
251
+ const [ validatedArgs , validationContext ] = getArgumentsAndValidationContext . call ( this , methodName , args , true ) ;
251
252
252
253
try {
253
- return await _super . apply ( this , args ) ;
254
+ return await _super . apply ( this , validatedArgs ) ;
254
255
} catch ( err ) {
255
256
if ( this . _c2 ) {
256
257
const addValidationErrorsPropName =
0 commit comments