I am using the following frameworks/libraries:
- Node.js
- Express.js
- node-mysql.js
- async.js
I am making multiple asynchronous queries to my DB, but each subsequent query relies on the results of the previous query, so I decided to use the waterfall method.
Right now, my code looks like this (I simplified it with only 2 queries, but there are more):
async.waterfall([
function(cb){
db.query(insertQuery,values,cb);
},
function(results,_,cb){
var lastInsertId = results.insertId;
db.query(anotherInsertQuery,otherValues.concat(lastInsertId),cb);
}
],callback);
But I found my code a bit messy, especially the function(cb) { ... } wraps.
Is there a way to get rid of those annoying function(cb){...} ?
node-mysql.js, since it's related with that, but I couldn't create it (not enough reputation). Do you think you could do that ? \$\endgroup\$async.jsexisted, with only one question so... But anyway, thanks for the welcome ! Sorry about that, I would like to know what's the cleanest way to do what I'm trying to do using theasync.jsmodule. What methods (apply,waterfall...) or structure should I use ? Is that more clear ? Do you think I should edit my question ? \$\endgroup\$