Javascript Async implementation with Google Firestore

Kavit (zenwraight)
techie
Published in
3 min readAug 26, 2020

--

Have you ever come across a situation where you write code, ask it to perform something and when you look at the output, you realize this is not what you wanted and why is it behaving in a different manner.

Something similar happened with me, let me state the problem statement first.

Disclaimer:- This article assumes you have prior knowledge of Node.js and Google Firestore.

Basics on How to Read Data from Google Firestore

Problem Statement

I have a list of categories of my shopping list with me and I have all the orders present inside my google firestore database. Let’s assume categories to be an array [pants, shorts, cap] and entries in the google firestore look like

{
"data": [
{
"category": "pants",
"cost": "$25"
},
{
"category": "shorts",
"cost": "$20"
},
{
"category": "cap",
"cost": "$5"
},
{
"category": "shorts",
"cost": "$15"
},
{
"category": "cap",
"cost": "$7"
}
]
}

Now, I want to basically visualize what’s the total cost of my shopping category wise.

Proposed Solution — Easy

  1. Fetch all the shopping list from…

--

--