Jsexxpress mysqlridis how do you layer?

  node.js, question

The first Virgo project of node.js has very simple functions, only developing several interfaces. Node.js uses 4.3, express uses 4.x, and the database uses mysql and redis. How do you layer when you use the database? At present, when I develop this project, I do not layer, but directly operate mysql and redis in routing js file inside. Mysql integrates a plug-in express-myconnection into express middleware and configures mysql’s connection string in app.js inside. Redis is also directly in the routing file inside createClient. How do you use it? If there is a Dao layer, how is the value transferred to the routing layer file at the Dao layer?

According to mvc, the dao layer can be defined in the model.

// model
 module.exports = class Table {
 constructor(){}
 select(){}
 insert(){}
 update(){}
 delete(){}
 bracket
 
 
 // route here you can add a layer of controller to route.
 
 app.get(/,(req, res, next)=>{
 
 var model = new Table()
 
 model.select()
 .then(data => res.json(data).end())
 .catch(next)
 })

All functions return promise

Do the interface development tightly and you don’t need to consider view.