From 8ce98ffbc95580bad04f0fb6b6091084a68626d5 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Tue, 10 Oct 2017 09:41:32 +1300 Subject: [PATCH 1/2] Provide realistic code example Current code example does `afDb.object('items').snapshotChanges()` which would give a key value of 'items' followed by all items. --- docs/version-5-upgrade.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/version-5-upgrade.md b/docs/version-5-upgrade.md index 502739e20..542c104a9 100644 --- a/docs/version-5-upgrade.md +++ b/docs/version-5-upgrade.md @@ -41,11 +41,14 @@ constructor(afDb: AngularFireDatabase) { ### 5.0 ```ts constructor(afDb: AngularFireDatabase) { - afDb.object('items').snapshotChanges().map(action => { - const $key = action.payload.key; - const data = { $key, ...action.payload.val() }; - return data; - }).subscribe(item => console.log(item.$key)); + afDb.list('items').snapshotChanges().map(action => { + const arr = []; + action.forEach(e => { + const $key = e.key; + arr.push({ $key, ...e.payload.val() }); + }); + return arr; + }).subscribe(items => items.forEach(item => console.log(item.$key))); } ``` From 3cee34fd56c093d77642f5041e129c19fa0606a4 Mon Sep 17 00:00:00 2001 From: Bob Lee Date: Sun, 15 Oct 2017 15:26:36 +1300 Subject: [PATCH 2/2] simpler code example --- docs/version-5-upgrade.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/version-5-upgrade.md b/docs/version-5-upgrade.md index 542c104a9..eb19e89b2 100644 --- a/docs/version-5-upgrade.md +++ b/docs/version-5-upgrade.md @@ -41,13 +41,8 @@ constructor(afDb: AngularFireDatabase) { ### 5.0 ```ts constructor(afDb: AngularFireDatabase) { - afDb.list('items').snapshotChanges().map(action => { - const arr = []; - action.forEach(e => { - const $key = e.key; - arr.push({ $key, ...e.payload.val() }); - }); - return arr; + afDb.list('items').snapshotChanges().map(actions => { + return actions.map(action => ({ $key: action.key, ...action.payload.val() })); }).subscribe(items => items.forEach(item => console.log(item.$key))); } ```