From 869c1019ef4d7433501ebc6429559cf5e57e360d Mon Sep 17 00:00:00 2001 From: Frieder Schrempf Date: Fri, 11 Oct 2019 19:57:07 +0200 Subject: [PATCH] Inline default resource structure to work around issue See here for more information: https://github.com/rmariuzzo/lowdb-api/issues/5 --- index.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/index.js b/index.js index 1596e70..399b1d8 100644 --- a/index.js +++ b/index.js @@ -148,11 +148,6 @@ function lowdbApi(file, options = {}) { * @private */ -const defaultResource = { - data: [], - metadata: {} -} - function all(db, key) { return db.get(`${key}.data`, []).value() } @@ -163,7 +158,7 @@ function get(db, key, id) { function insert(db, key, data) { // Ensure a resource entry exist for the given key. - db.defaults({ [key]: defaultResource }).write() + db.defaults({ [key]: { data: [], metadata: {} } }).write() // Generate the next id. if (typeof data.id === 'undefined') {