Registry / database / alien-node-mysql-utils

alien-node-mysql-utils

JSON →
library0.5.12jsnpmunverified

Helper functions for MySQL on NodeJS with pure, curried functions using Ramda. Version 0.5.12 (last published 2016, no longer actively maintained). Provides query, lookup, and transaction helpers that wrap mysql connection pools. Key differentiators: functions are curried via Ramda, and safe variants (querySafe, lookupSafe) return empty arrays/undefined instead of rejecting on no results. Note: package is outdated and unmaintained; use with caution or migrate to modern alternatives like mysql2 or knex.

npm install alien-node-mysql-utils
INSTALL
IMPORT
SIG · ALIEN-NODE-MYSQL-U
A
alien-node-mysql-utils
databasejavascriptv0.5.12
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.

default export
const DB = require('alien-node-mysql-utils')(dbPool);
const { query } = require('alien-node-mysql-utils');
The package exports a function that must be called with a mysql connection pool. It returns an object with methods query, lookup, etc.
query
const { query } = require('alien-node-mysql-utils')(dbPool);
const query = require('alien-node-mysql-utils').query;
Methods are returned only after invoking the exported function with a pool.
querySafe
const { querySafe } = require('alien-node-mysql-utils')(dbPool);
const querySafe = require('alien-node-mysql-utils/querySafe');
Subpath imports are not supported; all methods come from the same call.

Shows how to instantiate with a mysql pool and use query, querySafe, lookup, lookupSafe.

const mysql = require('mysql'); const pool = mysql.createPool({ host: 'localhost', user: 'root', password: '', database: 'test' }); const DB = require('alien-node-mysql-utils')(pool); // query: returns array of rows, rejects if none DB.query(['SELECT * FROM users WHERE active = ?', [1]]) .then(rows => console.log('Users:', rows)) .catch(err => console.error('Error:', err)); // querySafe: returns empty array if no rows DB.querySafe(['SELECT * FROM users WHERE active = ?', [1]]) .then(rows => console.log('Users (safe):', rows)) .catch(err => console.error('Error:', err)); // lookup: returns one row object, rejects if none DB.lookup(['SELECT * FROM users WHERE id = ?', [1]]) .then(user => console.log('User:', user)) .catch(err => console.error('Error:', err)); // lookupSafe: returns undefined if none DB.lookupSafe(['SELECT * FROM users WHERE id = ?', [999]]) .then(user => console.log('User (safe):', user)) .catch(err => console.error('Error:', err));
Debug
Known issues
deprecatedPackage last updated in 2016, no longer maintained.
fix
Migrate to modern MySQL libraries like mysql2 or knex.
affects: *
gotchaMust call exported function with a mysql pool to use methods.
fix
Use const DB = require('alien-node-mysql-utils')(pool); then DB.query(...).
affects: *
gotchaquery and lookup reject the promise if no rows found; use Safe variants to avoid errors.
fix
Use querySafe or lookupSafe for optional results.
affects: *
gotchaRequires peer dependency ramda and mysql; not included automatically.
fix
Install both: npm install ramda mysql.
affects: *
Errors
Common errors & fixes
TypeError: require(...) is not a function
Imported module without calling it with a pool.
fix
Use const DB = require('alien-node-mysql-utils')(pool);
Cannot read property 'query' of undefined
Tried to destructure methods without invoking the export first.
fix
Correctly instantiate: const { query } = require('alien-node-mysql-utils')(pool);
Error: No records found
query or lookup used when no rows exist.
fix
Use querySafe or lookupSafe instead if no result is acceptable.
Upgrade
Version history
0.5.12latest on npm
Audit
Dependencies
ramdarequiredUsed for function currying
mysqlrequiredPeer dependency for MySQL driver
Agent activity
30 hits · last 30 days
node
26
OpenAI (training)
1
Resources
alien-node-mysql-utils — npm install alien-node-mysql-utils · libregistry