From 29333499e00bb61840c1e4ee6250cd53ae48fc1a Mon Sep 17 00:00:00 2001 From: Paul Leroy <32666273+paulleroyza@users.noreply.github.com> Date: Fri, 31 Mar 2023 14:13:37 +0100 Subject: [PATCH] Add Document ID to response When doing any updates and changes we'd need a document id returned from a query, this would change the message structure but would honour the id/data structure of the API. --- firestore.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/firestore.js b/firestore.js index dc5b7ac..aeefaad 100644 --- a/firestore.js +++ b/firestore.js @@ -131,7 +131,7 @@ module.exports = function(RED) { const querySnapshot = await query.get(); let results = []; querySnapshot.forEach((queryDocumentSnapshot) => { - results.push(queryDocumentSnapshot.data()); + results.push({id:queryDocumentSnapshot.id,data:queryDocumentSnapshot.data()}); }); msg.payload = results; @@ -174,4 +174,4 @@ module.exports = function(RED) { RED.nodes.registerType(NODE_TYPE, FireStoreNode); -}; \ No newline at end of file +};