From 470c4954e33b35e09fd3e8774fb048bae6d4e8cf Mon Sep 17 00:00:00 2001 From: Shams mosowi Date: Thu, 17 Dec 2020 00:53:15 +0800 Subject: [PATCH] fix: algoliaIndex ingnoring false value fields --- FT_functions/sparksLib/algoliaIndex.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/FT_functions/sparksLib/algoliaIndex.ts b/FT_functions/sparksLib/algoliaIndex.ts index 0c24c5c4..d68b63c0 100644 --- a/FT_functions/sparksLib/algoliaIndex.ts +++ b/FT_functions/sparksLib/algoliaIndex.ts @@ -3,6 +3,7 @@ export const dependencies = { }; const isEmpty = (obj) => + obj !== false && [Object, Array].includes((obj || {}).constructor) && !Object.entries(obj || {}).length; const get = (obj, path, defaultValue = undefined) => { @@ -46,13 +47,13 @@ const rowReducer = (fieldsToSync, row) => ...acc, [curr]: row[curr].toDate().getTime() / 1000, }; - } else if (!isEmpty(row[curr])) { + } else if (row[curr] !== undefined || row[curr] !== null) { return { ...acc, [curr]: row[curr] }; } else { return acc; } } else { - if (!isEmpty(row[curr.fieldName]) && curr.snapshotFields) { + if (row[curr.fieldName] && curr.snapshotFields) { return { ...acc, [curr.fieldName]: row[curr.fieldName].map((snapshot) =>