I'm having great difficulty performing an action with firebase Realtime data.
I have this structure:
-contacts
--id
---name
---status
---valor
For example:
I'm trying to SUM all records with "RECEITA" status,with this code:
const filterStatus = () => {
fireDb.child("contacts").orderByChild("status").equalTo("Receita").on("value", (snapshot) => {
if(snapshot.val()) {
var sum = 0;
Object.keys(data).map((id, index) => {
sum += parseInt(data[id].valor);
console.log(sum)
})
}
}
)
}
but it's not returning anything, not even in console.log
How can I do this sum correctly?