A lightweight MySQL query builder for Node.js built on top of node-mysql. Version 0.8.6 is the latest stable release, with low release cadence and minimal maintenance. It provides a fluent API for building SELECT, INSERT, UPDATE, DELETE queries with automatic escaping and method chaining. Unlike full ORMs, it gives direct control over SQL while simplifying common patterns. It bundles node-mysql internally, so no extra dependencies are needed. Supports reconnection, raw queries, joins, grouping, and having clauses. However, it is limited to MySQL and ties closely to the callback-based node-mysql driver, lacking promise support.
npm install mysql-activerecordNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Demonstrates connecting to MySQL, selecting fields, applying a WHERE condition, ordering, and executing a callback-based query with the query builder.
Consider migrating to mysql2 or a promise-based library like knex or Sequelize.
Pin version and audit dependency tree; use Snyk or Dependabot.
Always call resetQuery() or use a new Adapter instance per query.
Use .where() with separate arguments: .where('field', [1,2,3]) instead of .where({ field: [1,2,3] }).Explicitly set reconnectTimeout in options if you need a specific value.
Run: npm install mysql-activerecord
Use: const Db = require('mysql-activerecord'); const db = new Db.Adapter(...);Create a new Adapter instance or ensure the connection is still open before calling query methods.
Check MySQL service: systemctl start mysql (Linux) or brew services start mysql (macOS). Verify host and port.