@@ -139,7 +139,7 @@ const valueAsDate = value => {
139
139
return false ;
140
140
}
141
141
142
- function transformQueryKeyValue ( className , key , value , { validate } = { } , parseFormatSchema ) {
142
+ function transformQueryKeyValue ( className , key , value , { validate } = { } , schema ) {
143
143
switch ( key ) {
144
144
case 'createdAt' :
145
145
if ( valueAsDate ( value ) ) {
@@ -168,12 +168,12 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
168
168
if ( ! ( value instanceof Array ) ) {
169
169
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'bad $or format - use an array value' ) ;
170
170
}
171
- return { key : '$or' , value : value . map ( subQuery => transformWhere ( className , subQuery , { } , parseFormatSchema ) ) } ;
171
+ return { key : '$or' , value : value . map ( subQuery => transformWhere ( className , subQuery , { } , schema ) ) } ;
172
172
case '$and' :
173
173
if ( ! ( value instanceof Array ) ) {
174
174
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'bad $and format - use an array value' ) ;
175
175
}
176
- return { key : '$and' , value : value . map ( subQuery => transformWhere ( className , subQuery , { } , parseFormatSchema ) ) } ;
176
+ return { key : '$and' , value : value . map ( subQuery => transformWhere ( className , subQuery , { } , schema ) ) } ;
177
177
default :
178
178
// Other auth data
179
179
const authDataMatch = key . match ( / ^ a u t h D a t a \. ( [ a - z A - Z 0 - 9 _ ] + ) \. i d $ / ) ;
@@ -188,16 +188,16 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
188
188
}
189
189
190
190
const expectedTypeIsArray =
191
- parseFormatSchema &&
192
- parseFormatSchema . fields [ key ] &&
193
- parseFormatSchema . fields [ key ] . type === 'Array' ;
191
+ schema &&
192
+ schema . fields [ key ] &&
193
+ schema . fields [ key ] . type === 'Array' ;
194
194
195
195
const expectedTypeIsPointer =
196
- parseFormatSchema &&
197
- parseFormatSchema . fields [ key ] &&
198
- parseFormatSchema . fields [ key ] . type === 'Pointer' ;
196
+ schema &&
197
+ schema . fields [ key ] &&
198
+ schema . fields [ key ] . type === 'Pointer' ;
199
199
200
- if ( expectedTypeIsPointer || ! parseFormatSchema && value && value . __type === 'Pointer' ) {
200
+ if ( expectedTypeIsPointer || ! schema && value && value . __type === 'Pointer' ) {
201
201
key = '_p_' + key ;
202
202
}
203
203
@@ -222,13 +222,13 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
222
222
// restWhere is the "where" clause in REST API form.
223
223
// Returns the mongo form of the query.
224
224
// Throws a Parse.Error if the input query is invalid.
225
- function transformWhere ( className , restWhere , { validate = true } = { } , parseFormatSchema ) {
225
+ function transformWhere ( className , restWhere , { validate = true } = { } , schema ) {
226
226
let mongoWhere = { } ;
227
227
if ( restWhere [ 'ACL' ] ) {
228
228
throw new Parse . Error ( Parse . Error . INVALID_QUERY , 'Cannot query on ACL.' ) ;
229
229
}
230
230
for ( let restKey in restWhere ) {
231
- let out = transformQueryKeyValue ( className , restKey , restWhere [ restKey ] , { validate } , parseFormatSchema ) ;
231
+ let out = transformQueryKeyValue ( className , restKey , restWhere [ restKey ] , { validate } , schema ) ;
232
232
mongoWhere [ out . key ] = out . value ;
233
233
}
234
234
return mongoWhere ;
0 commit comments