I want to call a function on the returned data from this database query, as in the snippet below.
function connectDB(query, data, callback) {
    pg.connect(process.env.DATABASE_URL, function (err, client) {
        if (err) {
            console.log(err);
        } else {
                client
                    .query(query, data, function (err, result) {
                        callback(result.rows);                            
                    });
        }
     }
}
function foo(data) {
  connectDB("SELECT * FROM mytable WHERE id=$1", someID, callbackfn(data));
}
I don't know how to write callbackfn so that I can use both data from the original function and rows from the db result.
function callbackfn(data) {
  return function(rows) {
   // Do something with rows and data
  }
}
 
     
     
    