Skip to content

Commit 71ae7be

Browse files
committed
better names and comments
1 parent 449ca11 commit 71ae7be

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/Adapters/Storage/Mongo/MongoStorageAdapter.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ export class MongoStorageAdapter {
173173
// If no objects match, reject with OBJECT_NOT_FOUND. If objects are found and deleted, resolve with undefined.
174174
// If there is some other error, reject with INTERNAL_SERVER_ERROR.
175175

176-
// Currently accepts the validate for lecacy reasons. Currently accepts the schema, that may not actually be necessary.
176+
// Currently accepts validate for legacy reasons. Currently accepts the schema, that may not actually be necessary.
177177
deleteObjectsByQuery(className, query, validate, schema) {
178178
return this.adaptiveCollection(className)
179179
.then(collection => {

src/Adapters/Storage/Mongo/MongoTransform.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ const valueAsDate = value => {
139139
return false;
140140
}
141141

142-
function transformQueryKeyValue(className, key, value, { validate } = {}, parseFormatSchema) {
142+
function transformQueryKeyValue(className, key, value, { validate } = {}, schema) {
143143
switch(key) {
144144
case 'createdAt':
145145
if (valueAsDate(value)) {
@@ -168,12 +168,12 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
168168
if (!(value instanceof Array)) {
169169
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'bad $or format - use an array value');
170170
}
171-
return {key: '$or', value: value.map(subQuery => transformWhere(className, subQuery, {}, parseFormatSchema))};
171+
return {key: '$or', value: value.map(subQuery => transformWhere(className, subQuery, {}, schema))};
172172
case '$and':
173173
if (!(value instanceof Array)) {
174174
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'bad $and format - use an array value');
175175
}
176-
return {key: '$and', value: value.map(subQuery => transformWhere(className, subQuery, {}, parseFormatSchema))};
176+
return {key: '$and', value: value.map(subQuery => transformWhere(className, subQuery, {}, schema))};
177177
default:
178178
// Other auth data
179179
const authDataMatch = key.match(/^authData\.([a-zA-Z0-9_]+)\.id$/);
@@ -188,16 +188,16 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
188188
}
189189

190190
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';
194194

195195
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';
199199

200-
if (expectedTypeIsPointer || !parseFormatSchema && value && value.__type === 'Pointer') {
200+
if (expectedTypeIsPointer || !schema && value && value.__type === 'Pointer') {
201201
key = '_p_' + key;
202202
}
203203

@@ -222,13 +222,13 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF
222222
// restWhere is the "where" clause in REST API form.
223223
// Returns the mongo form of the query.
224224
// 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) {
226226
let mongoWhere = {};
227227
if (restWhere['ACL']) {
228228
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Cannot query on ACL.');
229229
}
230230
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);
232232
mongoWhere[out.key] = out.value;
233233
}
234234
return mongoWhere;

0 commit comments

Comments
 (0)