Skip to content

Commit

Permalink
Delete schema promise on error...
Browse files Browse the repository at this point in the history
- Just because this way we can let the adapter an opportunity to yield a new error....
OR A SUCCESS
  • Loading branch information
flovilmart committed Jul 19, 2016
1 parent 867384f commit 377d5c4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Controllers/DatabaseController.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ DatabaseController.prototype.validateClassName = function(className) {
DatabaseController.prototype.loadSchema = function() {
if (!this.schemaPromise) {
this.schemaPromise = SchemaController.load(this.adapter);
this.schemaPromise.then(() => delete this.schemaPromise);
this.schemaPromise.then(() => delete this.schemaPromise,
() => delete this.schemaPromise);
}
return this.schemaPromise;
};
Expand Down Expand Up @@ -704,6 +705,7 @@ DatabaseController.prototype.find = function(className, query, {
let aclGroup = acl || [];
let op = typeof query.objectId == 'string' && Object.keys(query).length === 1 ? 'get' : 'find';
let classExists = true;
console.log('will load schema');
return this.loadSchema()
.then(schemaController => {
//Allow volatile classes if querying with Master (for _PushStatus)
Expand All @@ -717,6 +719,7 @@ DatabaseController.prototype.find = function(className, query, {
classExists = false;
return { fields: {} };
}
console.log('Cannot get one schema');
throw error;
})
.then(schema => {
Expand Down Expand Up @@ -767,6 +770,7 @@ DatabaseController.prototype.find = function(className, query, {
if (!classExists) {
return [];
} else {
console.log('adapter find');
return this.adapter.find(className, schema, query, { skip, limit, sort })
.then(objects => objects.map(object => {
object = untransformObjectACL(object);
Expand Down

0 comments on commit 377d5c4

Please sign in to comment.