From 91ff816839daf9099d117c95252f0da27963b27c Mon Sep 17 00:00:00 2001 From: Marco129 Date: Mon, 7 Mar 2016 14:14:28 +0800 Subject: [PATCH] Improve delete flow for non-existence _Join collection --- src/Schema.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Schema.js b/src/Schema.js index 0ed5552792..545b4953bf 100644 --- a/src/Schema.js +++ b/src/Schema.js @@ -409,10 +409,14 @@ class Schema { if (this.data[className][fieldName].startsWith('relation<')) { //For relations, drop the _Join table - return database.collectionExists(`_Join:${fieldName}:${className}`).then(exist => { - if (exist) { - return database.dropCollection(`_Join:${fieldName}:${className}`); + return database.dropCollection(`_Join:${fieldName}:${className}`) + .then(() => { + return Promise.resolve(); + }, error => { + if (error.message == 'ns not found') { + return Promise.resolve(); } + return Promise.reject(error); }); }