I need to send a few requests to the DB and update each entry from the response.
I am trying to use forEach/for but as far as forEach/for is async I can't find a way how to do a few requests to Firebase DB using cycle.  

Any ideas?  

Here is my code. I've tried to do work around with counter inside the cycle. But unfortunately, this not works for me.

```
function updateMethod(inputArray) {
    return new Promise((resolve, reject) => {
        var updates = {};
        var ctr = 0;
        for (let i = 0; i < inputArray.length; i++) {
            db.ref("/foo").orderByChild("finished").equalTo(inputArray[i]).once("value", (snapshot) => {
                ctr++;
                var key = snapshot.key;
                updates['transactions/' + key + '/finished'] = true;
                if (ctr === inputArray.length) {
                    resolve(updates);
                }
            }).catch((e) => {
                console.log(e);
            });
        }
    });
}

```

**So bottom line:**
I need to do a few requests inside cycle and then make a return from the method.