From 6b596a4021f6406903d1845618b9750b59eec73a Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Fri, 20 Dec 2019 11:56:52 +0530 Subject: [PATCH] feat: doc.push for adding children without change --- model/document.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/model/document.js b/model/document.js index 17b806b4..fad14a71 100644 --- a/model/document.js +++ b/model/document.js @@ -24,7 +24,7 @@ module.exports = class BaseDocument extends Observable { this[fieldname] = value; } else if (Array.isArray(value)) { for (let row of value) { - this.append(fieldname, row); + this.push(fieldname, row); } } else { this[fieldname] = value; @@ -146,12 +146,18 @@ module.exports = class BaseDocument extends Observable { } append(key, document = {}) { + // push child row and trigger change + this.push(key, document); + this._dirty = true; + this.applyChange(key); + } + + push(key, document = {}) { + // push child row without triggering change if (!this[key]) { this[key] = []; } this[key].push(this._initChild(document, key)); - this._dirty = true; - this.applyChange(key); } _initChild(data, key) {