From 4b4f4fd188e23ccbb480a5ebcd887f16c015f18a Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Tue, 2 Jun 2020 23:17:54 -0700 Subject: [PATCH] flow --- app/models/Document.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/models/Document.js b/app/models/Document.js index d39683576..7c912a3ec 100644 --- a/app/models/Document.js +++ b/app/models/Document.js @@ -186,13 +186,17 @@ export default class Document extends BaseModel { }); } - return await this.store.update({ - id: this.id, - title: this.title, - text: this.text, - lastRevision: options.lastRevision, - ...options, - }); + if (options.lastRevision) { + return await this.store.update({ + id: this.id, + title: this.title, + text: this.text, + lastRevision: options.lastRevision, + ...options, + }); + } + + throw new Error('Attempting to update without a lastRevision'); } finally { this.isSaving = false; }