I have a callable Cloudfunction that should fetch multiple data. The keys where to fetch from are calculated by the function.
I have an array like this
var keys = ["key1", "key2, "key5"]
The problem is that the length of the keylist is variable and i want to send all the datas gathered from the database at the given key back to the user.
Something like this:
result = {
key1: value,
key2: value,
key5: value,
}
The database only gives out Promisses that are not asnyc. How do I make sure that i only give out data, once all the data are gathered. Something like
admin.database().ref('/path/key1').once('value').then( snapshot => {
admin.database().ref('/path/key2').once('value').then ( snapshot => {
...
}
}
Won't work, because the number of keys is variable.