Move 'ns not found' into mongo adapter. (#1541)

This commit is contained in:
Drew
2016-04-18 17:06:51 -07:00
parent ab0ea09067
commit cecb2a1cb1
4 changed files with 12 additions and 27 deletions

View File

@@ -70,7 +70,7 @@ var removeJoinTables = (database, mongoSchema) => {
.filter(field => mongoSchema[field].startsWith('relation<'))
.map(field => {
let collectionName = `_Join:${field}:${mongoSchema._id}`;
return database.dropCollection(collectionName);
return database.adapter.dropCollection(collectionName);
})
);
};
@@ -94,17 +94,7 @@ function deleteSchema(req) {
return removeJoinTables(req.config.database, document);
});
})
.then(() => {
// Success
return { response: {} };
}, error => {
if (error.message == 'ns not found') {
// If they try to delete a non-existent class, that's fine, just let them.
return { response: {} };
}
return Promise.reject(error);
});
.then(() => ({ response: {} }));
}
export class SchemasRouter extends PromiseRouter {