Skip to content

Commit 53e7337

Browse files
committed
Merge pull request #881 from Marco129/fix-delete-field
Improve delete flow for non-existence _Join collection
2 parents b36fd6f + 91ff816 commit 53e7337

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)