So, I am trying to make a thing with discord js and sqlite3 but I've been stuck on this one issue for the past few hours and I still do not understand how I would resolve it.
  client.countDB = function(discordID) {
    const arr = [];
    db.each(`SELECT count(DiscordID) FROM verification WHERE DiscordID = ${discordID}`, function(err, row){
      if(err){console.log(err); return 0;}
      arr.push(Object.values(row))
      return arr;
    })
    return arr[0];
  };
So I am trying to get data that is only available in db.each but I do not know how I would pass it out so I can return the expected value. I've already tried using global variables, putting it in a larger scope, and I still cannot figure out how to do it.
Sorry if I am confusing I'm not used to asking questions all the time.
Edit: Should have said I'm using the npm sqlite3 module. https://www.npmjs.com/package/sqlite3
 
     
     
    