Reputation: 5308
Is there a short/efficient way to check if multiple keys exist (even better if I can read several keys in a single call)?
The only way I manage to achieve a similar result is by checking if key1
exists, .then
check if key2
exists etc. Make it very ugly if I have 5 keys to check.
The keys are in completely different locations, so I don't want to just get the common ancestor and read the snap, as it's too much data.
Upvotes: 0
Views: 89
Reputation: 317562
Check all the keys without using then(), but collect all the promises into an array (I'll call it promises
), then use Promise.all(promises)
to get another promise that's resolved after all the others resolve. They can now potentially execute in parallel without having to wait for each other.
Upvotes: 2