I am developing an app that uses Firebase cloud functions ( Node.js ) , what I want to achieve is to trigger a function when a child is created in node a , and then it reads another node b , loop through data snapshot and choose a single child based on filters :
{
"a": {
"id1": {
"filters": {
"field1": "value3"
}
}
},
"b": {
"child1": {
"field1": "value1",
"field2": "value2"
},
"child2": {
"field1": "value3",
"field2": "value4"
}
...
}
}
using orderByChild and equalTo is not enough because i have more than one filter and also i have a range filter (age between min and max) , so i have to loop through node "b" to choose the child.
my question is can i store node "b" in a global variable ( array ) instead of reading the entire node b each time ( i will read from the variable instead ) ? if yes is there a size limit to that variable ? and would it be faster than reading from database each time ?
node a, it'd be helpful to review structure ofnode band thereby the logic.onWriteofnode a, how do you intend to storenode boutside the scope of the function?