Move "No two geopoints" logic into mongo adapter (#1491)

* Move "No two geopoints" logic into mongo adapter

* Semicolon
This commit is contained in:
Drew
2016-04-18 17:10:30 -07:00
parent cecb2a1cb1
commit 0708af17d7
4 changed files with 51 additions and 39 deletions

View File

@@ -346,23 +346,20 @@ function CannotTransform() {}
// Raises an error if this cannot possibly be valid REST format.
// Returns CannotTransform if it's just not an atom, or if force is
// true, throws an error.
function transformAtom(atom, force, options) {
options = options || {};
var inArray = options.inArray;
var inObject = options.inObject;
function transformAtom(atom, force, {
inArray,
inObject,
} = {}) {
switch(typeof atom) {
case 'string':
case 'number':
case 'boolean':
return atom;
case 'undefined':
return atom;
case 'symbol':
case 'function':
throw new Parse.Error(Parse.Error.INVALID_JSON,
'cannot transform value: ' + atom);
throw new Parse.Error(Parse.Error.INVALID_JSON, `cannot transform value: ${atom}`);
case 'object':
if (atom instanceof Date) {
// Technically dates are not rest format, but, it seems pretty
@@ -377,7 +374,7 @@ function transformAtom(atom, force, options) {
// TODO: check validity harder for the __type-defined types
if (atom.__type == 'Pointer') {
if (!inArray && !inObject) {
return atom.className + '$' + atom.objectId;
return `${atom.className}$${atom.objectId}`;
}
return {
__type: 'Pointer',
@@ -402,15 +399,13 @@ function transformAtom(atom, force, options) {
}
if (force) {
throw new Parse.Error(Parse.Error.INVALID_JSON,
'bad atom: ' + atom);
throw new Parse.Error(Parse.Error.INVALID_JSON, `bad atom: ${atom}`);
}
return CannotTransform;
default:
// I don't think typeof can ever let us get here
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR,
'really did not expect value: ' + atom);
throw new Parse.Error(Parse.Error.INTERNAL_SERVER_ERROR, `really did not expect value: ${atom}`);
}
}