diff --git a/server/api/documents.js b/server/api/documents.js index 4aef31d1..2fef9508 100644 --- a/server/api/documents.js +++ b/server/api/documents.js @@ -119,6 +119,9 @@ router.post('documents.delete', auth(), async (ctx) => { if (!document) throw httpErrors.BadRequest(); + // TODO: Don't allow to destroy root docs + // TODO: handle sub documents + try { await document.destroy(); } catch (e) { diff --git a/server/models/Atlas.js b/server/models/Atlas.js index 1550a1e6..a0bcb6f6 100644 --- a/server/models/Atlas.js +++ b/server/models/Atlas.js @@ -56,7 +56,11 @@ const Atlas = sequelize.define('atlas', { atlasId: this.id, }}); - return await getNodeForDocument(rootDocument); + if (rootDocument) { + return await getNodeForDocument(rootDocument); + } else { + return; // TODO should create a root doc + } } } });