Skip to content

Commit 91ff816

Browse files
committed
Improve delete flow for non-existence _Join collection
1 parent b36fd6f commit 91ff816

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Schema.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -409,10 +409,14 @@ class Schema {
409409

410410
if (this.data[className][fieldName].startsWith('relation<')) {
411411
//For relations, drop the _Join table
412-
return database.collectionExists(`_Join:${fieldName}:${className}`).then(exist => {
413-
if (exist) {
414-
return database.dropCollection(`_Join:${fieldName}:${className}`);
412+
return database.dropCollection(`_Join:${fieldName}:${className}`)
413+
.then(() => {
414+
return Promise.resolve();
415+
}, error => {
416+
if (error.message == 'ns not found') {
417+
return Promise.resolve();
415418
}
419+
return Promise.reject(error);
416420
});
417421
}
418422

0 commit comments

Comments
 (0)