From b918eea6304f48b7f4edb71b333bc45db6bc9ea6 Mon Sep 17 00:00:00 2001 From: Salakar Date: Thu, 12 Apr 2018 12:38:28 +0100 Subject: [PATCH] [firestore] add support for `DocumentSnapshot.get('dot.notated.field.path')` --- lib/modules/firestore/DocumentSnapshot.js | 3 ++- lib/utils/index.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/modules/firestore/DocumentSnapshot.js b/lib/modules/firestore/DocumentSnapshot.js index d7317e79..aae8dc7e 100644 --- a/lib/modules/firestore/DocumentSnapshot.js +++ b/lib/modules/firestore/DocumentSnapshot.js @@ -63,6 +63,7 @@ export default class DocumentSnapshot { if (fieldPath instanceof FieldPath) { return extractFieldPathData(this._data, fieldPath._segments); } - return this._data ? deepGet(this._data, fieldPath, '.') : undefined; + + return deepGet(this._data, fieldPath, '.'); } } diff --git a/lib/utils/index.js b/lib/utils/index.js index ca9f1973..dc539b14 100644 --- a/lib/utils/index.js +++ b/lib/utils/index.js @@ -25,6 +25,7 @@ export function deepGet( path: string, joiner?: string = '/' ): any { + if (!isObject(object)) return undefined; const keys = path.split(joiner); let i = 0;