[database][js] fixed a regression where snapshot.child() would no longer work on array values

This commit is contained in:
Salakar
2018-04-22 00:29:33 +01:00
parent 0a828aae40
commit d0b6972e39
2 changed files with 5 additions and 4 deletions

View File

@@ -51,6 +51,7 @@ export default class DataSnapshot {
* @returns {Snapshot}
*/
child(path: string): DataSnapshot {
// TODO validate path is a string
let value = deepGet(this._value, path);
if (value === undefined) value = null;
const childRef = this.ref.child(path);
@@ -59,9 +60,9 @@ export default class DataSnapshot {
key: childRef.key,
exists: value !== null,
// todo this is wrong - child keys needs to be the ordered keys, from FB
// todo potential solution is build up a tree/map of a snapshot and its children
// todo natively and send that back to JS to be use in this class.
// TODO this is wrong - child keys needs to be the ordered keys, from FB
// TODO potential solution is build up a tree/map of a snapshot and its children
// TODO natively and send that back to JS to be use in this class.
// null check to keep flow happy even though isObject already does this
childKeys: isObject(value) && value !== null ? Object.keys(value) : [],