Skip to content
This repository was archived by the owner on Oct 6, 2026. It is now read-only.
pardnioPublic archive

About

A Node.js MySQL connection pool with read-write splitting, a chainable query builder, and slow query logging

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

10 Commits

Folders and files

Repository files navigation

Last updated: 2026-10-07

Note

This README was generated by SKILL, get the ZH version from here.


CHAIN YOUR MYSQL QUERIES ACROSS READ AND WRITE POOLS!

npm Downloads License


A Node.js MySQL connection pool with read-write splitting, a chainable query builder, and slow query logging

Table of Contents

Features

npm install @pardnchiu/mysql-pool · Documentation

  • Read-Write Split Pools — Maintains separate read and write connection pools, configured from an object or DB_READ_*/DB_WRITE_* environment variables, with the write side falling back to the read config when omitted.
  • Chainable Query Builder — Chain select, where, join, orderBy, and limit from table() through get(), binding every value through placeholders instead of string concatenation.
  • Pagination Total in One Query — total() attaches the full row count via the COUNT(*) OVER() window function, so paging never needs a second COUNT query.
  • UPSERT with MySQL Function Allowlist — Values matching allowlisted functions such as NOW() and UUID() are inlined into SQL while everything else is bound as a parameter.
  • Slow Query Logging and Graceful Shutdown — Logs the duration and SQL of any query over 20ms and releases both pools automatically on SIGINT/SIGTERM.

Architecture

Full Architecture

graph TB
    App[Application] --> Init["init()"]
    Init --> Cfg[Config Resolution<br/>object / env vars]
    Cfg --> RP[(Read Pool)]
    Cfg --> WP[(Write Pool)]
    App --> QB[Chainable Query Builder]
    App --> Raw["read() / write()"]
    QB --> Exec["query() Executor<br/>slow query log"]
    Raw --> Exec
    Exec --> RP
    Exec --> WP
Loading

License

This project is licensed under the MIT LICENSE.

Author

Just open an issue to share an idea.

node-mysql-pool contributors

©️ 2025 邱敬幃 Pardn Chiu

About

A Node.js MySQL connection pool with read-write splitting, a chainable query builder, and slow query logging

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Used by

Contributors

Languages