Skip to content

Commit 8ce98ff

Browse files
authored
Provide realistic code example
Current code example does `afDb.object('items').snapshotChanges()` which would give a key value of 'items' followed by all items.
1 parent 9039fc4 commit 8ce98ff

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

docs/version-5-upgrade.md

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,14 @@ constructor(afDb: AngularFireDatabase) {
4141
### 5.0
4242
```ts
4343
constructor(afDb: AngularFireDatabase) {
44-
afDb.object('items').snapshotChanges().map(action => {
45-
const $key = action.payload.key;
46-
const data = { $key, ...action.payload.val() };
47-
return data;
48-
}).subscribe(item => console.log(item.$key));
44+
afDb.list('items').snapshotChanges().map(action => {
45+
const arr = [];
46+
action.forEach(e => {
47+
const $key = e.key;
48+
arr.push({ $key, ...e.payload.val() });
49+
});
50+
return arr;
51+
}).subscribe(items => items.forEach(item => console.log(item.$key)));
4952
}
5053
```
5154

0 commit comments

Comments
 (0)