Improve delete flow for non-existence _Join collection

This commit is contained in:
Marco129
2016-03-07 14:14:28 +08:00
parent b36fd6f245
commit 91ff816839

View File

@@ -409,10 +409,14 @@ class Schema {
if (this.data[className][fieldName].startsWith('relation<')) { if (this.data[className][fieldName].startsWith('relation<')) {
//For relations, drop the _Join table //For relations, drop the _Join table
return database.collectionExists(`_Join:${fieldName}:${className}`).then(exist => { return database.dropCollection(`_Join:${fieldName}:${className}`)
if (exist) { .then(() => {
return database.dropCollection(`_Join:${fieldName}:${className}`); return Promise.resolve();
}, error => {
if (error.message == 'ns not found') {
return Promise.resolve();
} }
return Promise.reject(error);
}); });
} }