From 6ca78a19ea7d611605ddf82f151c13c6534ac098 Mon Sep 17 00:00:00 2001 From: Chaitanya Bhagvan Date: Thu, 17 Nov 2016 11:46:52 +0530 Subject: [PATCH 1/2] forEach and map method on the DataSnapshot does not retain key --- lib/modules/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/database.js b/lib/modules/database.js index 5c4b27e..ff59c74 100644 --- a/lib/modules/database.js +++ b/lib/modules/database.js @@ -35,7 +35,7 @@ class DataSnapshot { forEach(fn) { (this.childKeys || []) - .forEach(key => fn(this.value[key])) + .forEach(key => fn({key: key, value: this.value[key]})) } map(fn) { From 80133de8316729a851610ee6d326c73a642dde32 Mon Sep 17 00:00:00 2001 From: Chaitanya Bhagvan Date: Thu, 17 Nov 2016 12:30:32 +0530 Subject: [PATCH 2/2] Fixed error calling length of undefined --- lib/modules/database.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/modules/database.js b/lib/modules/database.js index ff59c74..1112919 100644 --- a/lib/modules/database.js +++ b/lib/modules/database.js @@ -232,7 +232,7 @@ class DatabaseRef extends ReferenceBase { const path = this.dbPath(); return this.db.off(path, evt, origCB) .then(({callback, subscriptions}) => { - if (dbSubscriptions[path] && dbSubscriptions[path][evt].length > 0) { + if (dbSubscriptions[path] && dbSubscriptions[path][evt] && dbSubscriptions[path][evt].length > 0) { return subscriptions; }