Registry / database / node-mysql-transaction

node-mysql-transaction

JSON →
library0.2.1jsnpmunverified

A transaction wrapper for the node-mysql 2.x driver, providing a callback queue with dynamic connection pooling to manage MySQL transactions. Version 0.2.1 is the current stable release, targeting Node.js 0.12. It offers chain-based query methods with auto-commit and rollback, allowing flexible transaction scopes. Differentiators include dynamic connection handling, idle connection cleanup, and timeout-based rollback. The package is unmaintained and should not be used in new projects.

npm install node-mysql-transaction
INSTALL
IMPORT
SIG · NODE-MYSQL-TRANSAC
N
node-mysql-transaction
databasejavascriptv0.2.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

node-mysql-transaction
var transaction = require('node-mysql-transaction');
import transaction from 'node-mysql-transaction';
CommonJS require is the only supported import style; there are no TypeScript definitions.
chain
var chain = trCon.chain();
var chain = transaction.chain();
chain() is a method on the transaction instance (trCon), not on the required module directly.
query
chain.query('INSERT ...', [params]);
chain.query('INSERT ...', params);
Parameters must be in an array, similar to node-mysql's query method.

Initialize transaction object, create a chain, attach commit/rollback listeners, and execute queries.

var mysql = require('mysql'); var transaction = require('node-mysql-transaction'); var trCon = transaction({ connection: [mysql.createConnection, { user: 'your_user', password: 'your_password', database: 'your_db' }], dynamicConnection: 32, idleConnectionCutoffTime: 1000, timeout: 600 }); var chain = trCon.chain(); chain .on('commit', function() { console.log('Transaction committed'); }) .on('rollback', function(err) { console.log('Rollback due to:', err); }); chain.query('INSERT INTO users (name) VALUES (?)', ['Alice']); chain.query('UPDATE users SET name = ? WHERE id = 1', ['Bob']);
Debug
Known issues
deprecatedPackage is unmaintained and relies on Node.js 0.12; not compatible with modern Node.js versions.
fix
Use a maintained MySQL transaction library like mysql2 or knex.
affects: >=0.2.1
gotchaDynamic connection feature may cause memory leaks if idleConnectionCutoffTime is set too high.
fix
Monitor connection counts and adjust idleConnectionCutoffTime appropriately.
affects: >=0.1.0
gotchaAuto-commit is enabled by default; forgetting to chain .autoCommit(false) can lead to premature commits.
fix
Explicitly call .autoCommit(false) if you want to control commit manually.
affects: >=0.1.0
breakingOnly supports node-mysql 2.x driver; incompatible with mysql2 or other MySQL drivers.
fix
Use the mysql package version 2.x or switch to a different transaction library.
affects: >=0.1.0
Errors
Common errors & fixes
Cannot find module 'node-mysql-transaction'
Package not installed or npm install failed due to outdated dependencies.
fix
Run 'npm install node-mysql-transaction' and ensure Node.js 0.12 compatibility.
TypeError: trCon.chain is not a function
Using require('node-mysql-transaction') directly as a function without calling transaction() first.
fix
Call transaction({...}) with configuration to create the transaction instance, then call chain() on it.
ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost' (using password: YES)
Invalid MySQL credentials passed to mysql.createConnection.
fix
Verify user, password, and host in the connection config object.
Upgrade
Version history
0.2.1latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency: node-mysql 2.x driver required for connection configuration.
Agent activity
2 hits · last 30 days
node
2
Resources
node-mysql-transaction — npm install node-mysql-transaction · libregistry