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

@@ -479,18 +479,11 @@ class SchemaController {
return Promise.resolve(this);
}
if (type === 'GeoPoint') {
// Make sure there are not other geopoint fields
for (let otherKey in this.data[className]) {
if (this.data[className][otherKey].type === 'GeoPoint') {
throw new Parse.Error(
Parse.Error.INCORRECT_TYPE,
'there can only be one geopoint field in a class');
}
}
if (typeof type === 'string') {
type = { type };
}
return this._collection.updateField(className, fieldName, type).then(() => {
return this._collection.addFieldIfNotExists(className, fieldName, type).then(() => {
// The update succeeded. Reload the schema
return this.reloadData();
}, () => {