Begin isolating object creation code into an externalizable API. (#1569)
* Tidy up transformKeyValue * Specialize transformKeyValue for object creation * remove keys that never appear in creation requests * rename function * remove local var * early exit for simple keys * Refactor create * Force class creation when creating an object * Pass parameters to key value transformer * No need to check for array in this func * start using Parse Format schema in MongoTransform * Remove call to getExpectedType * add tests to ensure client can't see _PushStatus
This commit is contained in:
@@ -312,24 +312,19 @@ DatabaseController.prototype.create = function(className, object, options = {})
|
||||
let originalObject = object;
|
||||
object = deepcopy(object);
|
||||
|
||||
var schema;
|
||||
var isMaster = !('acl' in options);
|
||||
var aclGroup = options.acl || [];
|
||||
|
||||
return this.validateClassName(className)
|
||||
.then(() => this.loadSchema())
|
||||
.then(s => {
|
||||
schema = s;
|
||||
if (!isMaster) {
|
||||
return schema.validatePermission(className, aclGroup, 'create');
|
||||
}
|
||||
return Promise.resolve();
|
||||
})
|
||||
.then(() => this.loadSchema())
|
||||
.then(schemaController => {
|
||||
return (isMaster ? Promise.resolve() : schemaController.validatePermission(className, aclGroup, 'create'))
|
||||
.then(() => this.handleRelationUpdates(className, null, object))
|
||||
.then(() => this.adapter.createObject(className, object, schema))
|
||||
.then(result => {
|
||||
return sanitizeDatabaseResult(originalObject, result.ops[0]);
|
||||
});
|
||||
.then(() => schemaController.enforceClassExists(className))
|
||||
.then(() => schemaController.getOneSchema(className))
|
||||
.then(schema => this.adapter.createObject(className, object, schemaController, schema))
|
||||
.then(result => sanitizeDatabaseResult(originalObject, result.ops[0]));
|
||||
})
|
||||
};
|
||||
|
||||
DatabaseController.prototype.canAddField = function(schema, className, object, aclGroup) {
|
||||
|
||||
Reference in New Issue
Block a user