diff --git a/src/helpers/query/utils.js b/src/helpers/query/utils.js index ca06fa87c..96b661004 100644 --- a/src/helpers/query/utils.js +++ b/src/helpers/query/utils.js @@ -200,9 +200,13 @@ export const fetchDocumentsById = async (collection, docIds, select = [], db = F return response.data .filter(({ found }) => found) .map(({ found }) => { - const [, , collectionName, docId] = found.name.split('/'); + // Deconstruct the document path as Firebase conveniently doesn't return basic information like the record ID as + // part of the documentation data. Whilst this is a bit hacky, it works. + const pathParts = found.name.split('/'); + const documentId = pathParts.pop(); + const collectionName = pathParts.pop(); return { - id: docId, + id: documentId, collection: collectionName, ..._mapValues(found.fields, (value) => convertValues(value)), };