Move query logic into mongo (#1885)

* Move Parse Server logic into Parse Server and out of MongoAdapter

* Move untransforming up one level

* Make find() in MongoStorageAdapter

* Put nested object untransforming into it's own function

* Simplfy nested untransform

* Don't mess with inner object keys called _auth_data_*

* Prevent untransforming inner object keys named _p_*

* Fix inner keys named _rperm, _wperm

* Fix bugs with inner objects behaving strange when other fields have same name as key in specific circumstances

* remove params from untransform nested object

* Revert changes to find
This commit is contained in:
Drew
2016-05-23 16:31:51 -07:00
committed by Florent Vilmart
parent 88fa7bad92
commit 614e1ac8e5
6 changed files with 184 additions and 124 deletions

View File

@@ -146,12 +146,8 @@ DatabaseController.prototype.validateObject = function(className, object, query,
});
};
// Like transform.untransformObject but you need to provide a className.
// Filters out any data that shouldn't be on this REST-formatted object.
DatabaseController.prototype.untransformObject = function(
schema, isMaster, aclGroup, className, mongoObject) {
var object = this.transform.untransformObject(schema, className, mongoObject);
const filterSensitiveData = (isMaster, aclGroup, className, object) => {
if (className !== '_User') {
return object;
}
@@ -705,12 +701,8 @@ DatabaseController.prototype.find = function(className, query, {
delete mongoOptions.limit;
return collection.count(mongoWhere, mongoOptions);
} else {
return collection.find(mongoWhere, mongoOptions)
.then(mongoResults => {
return mongoResults.map(result => {
return this.untransformObject(schemaController, isMaster, aclGroup, className, result);
});
});
return this.adapter.find(className, mongoWhere, mongoOptions, schemaController)
.then(objects => objects.map(object => filterSensitiveData(isMaster, aclGroup, className, object)));
}
});
});