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:
@@ -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)));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user