Unnesting Node database calls
问题 I have an ordinary var express = require('express') Node express www page, using session, pug, etc as usual. My db calls var db = require('./scripts/myHappyMysqlScript') I'm naturally using mysql , so in the db script var mysql = require('mysql') So for example app.get('/catPhotos', (req, response) => { response.render('catPhotos.pug'); }) Say a page has a table showing something from the petNames database, app.get('/pets', function(req, res, next) { db.allPetNames(function(err, petsList) {