From 71ae7bee945c7a341b3935e6b7fce14bfa058438 Mon Sep 17 00:00:00 2001 From: Drew Gross Date: Tue, 26 Apr 2016 13:08:58 -0700 Subject: [PATCH] better names and comments --- .../Storage/Mongo/MongoStorageAdapter.js | 2 +- src/Adapters/Storage/Mongo/MongoTransform.js | 24 +++++++++---------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js index f6467386..d61df40c 100644 --- a/src/Adapters/Storage/Mongo/MongoStorageAdapter.js +++ b/src/Adapters/Storage/Mongo/MongoStorageAdapter.js @@ -173,7 +173,7 @@ export class MongoStorageAdapter { // If no objects match, reject with OBJECT_NOT_FOUND. If objects are found and deleted, resolve with undefined. // If there is some other error, reject with INTERNAL_SERVER_ERROR. - // Currently accepts the validate for lecacy reasons. Currently accepts the schema, that may not actually be necessary. + // Currently accepts validate for legacy reasons. Currently accepts the schema, that may not actually be necessary. deleteObjectsByQuery(className, query, validate, schema) { return this.adaptiveCollection(className) .then(collection => { diff --git a/src/Adapters/Storage/Mongo/MongoTransform.js b/src/Adapters/Storage/Mongo/MongoTransform.js index ba9d3992..0013a39d 100644 --- a/src/Adapters/Storage/Mongo/MongoTransform.js +++ b/src/Adapters/Storage/Mongo/MongoTransform.js @@ -139,7 +139,7 @@ const valueAsDate = value => { return false; } -function transformQueryKeyValue(className, key, value, { validate } = {}, parseFormatSchema) { +function transformQueryKeyValue(className, key, value, { validate } = {}, schema) { switch(key) { case 'createdAt': if (valueAsDate(value)) { @@ -168,12 +168,12 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF if (!(value instanceof Array)) { throw new Parse.Error(Parse.Error.INVALID_QUERY, 'bad $or format - use an array value'); } - return {key: '$or', value: value.map(subQuery => transformWhere(className, subQuery, {}, parseFormatSchema))}; + return {key: '$or', value: value.map(subQuery => transformWhere(className, subQuery, {}, schema))}; case '$and': if (!(value instanceof Array)) { throw new Parse.Error(Parse.Error.INVALID_QUERY, 'bad $and format - use an array value'); } - return {key: '$and', value: value.map(subQuery => transformWhere(className, subQuery, {}, parseFormatSchema))}; + return {key: '$and', value: value.map(subQuery => transformWhere(className, subQuery, {}, schema))}; default: // Other auth data const authDataMatch = key.match(/^authData\.([a-zA-Z0-9_]+)\.id$/); @@ -188,16 +188,16 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF } const expectedTypeIsArray = - parseFormatSchema && - parseFormatSchema.fields[key] && - parseFormatSchema.fields[key].type === 'Array'; + schema && + schema.fields[key] && + schema.fields[key].type === 'Array'; const expectedTypeIsPointer = - parseFormatSchema && - parseFormatSchema.fields[key] && - parseFormatSchema.fields[key].type === 'Pointer'; + schema && + schema.fields[key] && + schema.fields[key].type === 'Pointer'; - if (expectedTypeIsPointer || !parseFormatSchema && value && value.__type === 'Pointer') { + if (expectedTypeIsPointer || !schema && value && value.__type === 'Pointer') { key = '_p_' + key; } @@ -222,13 +222,13 @@ function transformQueryKeyValue(className, key, value, { validate } = {}, parseF // restWhere is the "where" clause in REST API form. // Returns the mongo form of the query. // Throws a Parse.Error if the input query is invalid. -function transformWhere(className, restWhere, { validate = true } = {}, parseFormatSchema) { +function transformWhere(className, restWhere, { validate = true } = {}, schema) { let mongoWhere = {}; if (restWhere['ACL']) { throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Cannot query on ACL.'); } for (let restKey in restWhere) { - let out = transformQueryKeyValue(className, restKey, restWhere[restKey], { validate }, parseFormatSchema); + let out = transformQueryKeyValue(className, restKey, restWhere[restKey], { validate }, schema); mongoWhere[out.key] = out.value; } return mongoWhere;