Proper architecture for Node.js modules and database connectivity?

后端 未结 1 897
遥遥无期
遥遥无期 2021-01-01 04:24

I\'m writing a Node app that accepts TCP connections. I have a few separate Node modules (utilizing the exports functionality). Each needs a database connection to handle so

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 05:10

    imo best approach is to initialize connections pool and use it in modules passing as parameter. mysql-pool is quite generic and easily adaptable to any db client

    upd: node-pool is a generic db-agnostic pool

    0 讨论(0)
提交回复
热议问题