Skip to content

Commit d7d4f64

Browse files
authored
Provide realistic code example (#1237)
Provide realistic code example
2 parents 97f8fe1 + aefb30e commit d7d4f64

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

docs/version-5-upgrade.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ Calling `.valueChanges()` returns an Observable without any metadata. If you are
3434
### 4.0
3535
```ts
3636
constructor(afDb: AngularFireDatabase) {
37-
afDb.object('items/1').subscribe(item => console.log(item.$key));
37+
afDb.list('items').subscribe(items => {
38+
const allKeys = items.map(item => item.$key);
39+
});
3840
}
3941
```
4042

4143
### 5.0
4244
```ts
4345
constructor(afDb: AngularFireDatabase) {
44-
afDb.object('items/1').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));
46+
afDb.list('items').snapshotChanges().map(actions => {
47+
return actions.map(action => ({ key: action.key, ...action.payload.val() }));
48+
}).subscribe(items => {
49+
return items.map(item => item.key);
50+
});
4951
}
5052
```
5153

0 commit comments

Comments
 (0)