From 7ea6eb5d2876aff4d117fa7dd5b366ac3b73a862 Mon Sep 17 00:00:00 2001 From: Jori Lallo Date: Thu, 23 Jun 2016 00:19:45 -0700 Subject: [PATCH] Fixes --- server/api/documents.js | 3 +++ server/models/Atlas.js | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) 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 + } } } });