Schema Cache Improvement 2 (#5616)

* schema hasClass improvement

* create object improvement

* destroy object

* update object

* hasClass test rewrite

* more tests

* improve signing up users
This commit is contained in:
Diamond Lewis
2019-05-30 11:14:05 -05:00
committed by GitHub
parent 9f226a254a
commit cc6d474dcb
8 changed files with 572 additions and 405 deletions

View File

@@ -646,7 +646,7 @@ export default class SchemaController {
fields: SchemaFields = {},
classLevelPermissions: any,
indexes: any = {}
): Promise<void> {
): Promise<void | Schema> {
var validationError = this.validateNewClass(
className,
fields,
@@ -667,11 +667,6 @@ export default class SchemaController {
})
)
.then(convertAdapterSchemaToParseSchema)
.then(res => {
return this._cache.clear().then(() => {
return Promise.resolve(res);
});
})
.catch(error => {
if (error && error.code === Parse.Error.DUPLICATE_VALUE) {
throw new Parse.Error(
@@ -1285,6 +1280,9 @@ export default class SchemaController {
// Checks if a given class is in the schema.
hasClass(className: string) {
if (this.schemaData[className]) {
return Promise.resolve(true);
}
return this.reloadData().then(() => !!this.schemaData[className]);
}
}