How to detect when forEach ends in firebase

426
January 27, 2017, at 05:55 AM

How to detect when this iteration has ended? This snapshot forEach: reciptSnap. I need to execute a function after this but placing the .then()┬┤after the once() seems to work parallel , so I don't know how to say when it's done. I have read about async and promises but I don't understand well just async.series which i'm using for other scenarios

   ref.child("recipts").once("value", function(usersSnap) {
    usersSnap.forEach(function(reciptsSnap) { //for every user 
      reciptsSnap.forEach(function(reciptSnap) {
        reciptSnap.forEach(function(b) {
       })
      });
    });
  });

Just to let you know I try :

  reciptSnap.forEach(function(b,c,d) {
          console.log(c)
          console.log(d.length)

but it marks cannot read lenght of undefined Acoording to this question : Callback after all asynchronous forEach callbacks are completed

READ ALSO
See byte array per byte in NodeJs

See byte array per byte in NodeJs

I am porting custom decoding logic fromNet to NodeJS

472
ExpressJS and Socket.IO with Route/Socket Separation

ExpressJS and Socket.IO with Route/Socket Separation

Closest question/answer I could find as per: ExpressJS - SocketIO with Route Separation

391
How to insert more than one record in Same document at various timings?

How to insert more than one record in Same document at various timings?

Sending record through mqtt subscriberIf my payload is {"_id":"100","No":"1"} here in cloudant it will create a _id 100 and store No :1 but if I try to insert {"_id":"100","No":"2"} under same_id it simply override the existing No : 1

317
node.js sql.connect returns no errors, no output from callback

node.js sql.connect returns no errors, no output from callback

Pretty basic node Sql script, nothing fancy as yetLooping over a directory of files, I read in each file, parse it to JSON, and if there is a Count > 0, try to connect to sql to eventually push some data

363