Registry / database / mysql-kit

mysql-kit

JSON →
library0.3.0jsnpmunverified

A lightweight MySQL toolkit built on top of the `mysql` npm package that provides promisified query methods and common CRUD shorthand operations (find, findOne, insert, update, etc.). Current stable version is 0.3.0 with a low release cadence (last release Sep 2019). Key differentiators: minimal abstraction over raw `mysql` queries, synchronous-looking async API, and built-in helper methods for common operations. Does not use connection pooling natively (delegates to `mysql`). Suitable for simple scripts or small projects needing a thin wrapper.

npm install mysql-kit
INSTALL
IMPORT
SIG · MYSQL-KIT
M
mysql-kit
databasejavascriptv0.3.0
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.

connect
✓ import connect from 'mysql-kit'
✗ import { connect } from 'mysql-kit'
Default export – named import will not work.
query
✓ import connect, { query } from 'mysql-kit'
✗ import { query } from 'mysql-kit' (missing default import for connect)
query is a named export; must be used after connecting.
findOneById
✓ import connect, { findOneById } from 'mysql-kit'
✗ const { findOneById } = require('mysql-kit') (CJS require may not work with ESM-style bundle)
Named exports for helper methods; requires connection first.

Demonstrates connecting to MySQL, executing a raw query, and using a shorthand method to find a row by ID.

import connect, { query, findOneById } from 'mysql-kit'; const config = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test', }; await connect(config); const tables = await query('SHOW TABLES'); console.log('Tables:', tables); // Shorthand example const row = await findOneById('users', 1); console.log('User:', row);
Debug
Known issues
gotchaVersion 0.2.0 included a breaking change: `connect` is now async and must be awaited.
fix
Use `await connect(config)` instead of `connect(config)`.
affects: >=0.2.0
gotchaThe `query` function is not a connection pool manage – it uses the last connection created by `connect`. Calling `connect` again reinitializes the active connection.
fix
Call `connect` only once at startup, or add explicit connection management if needed.
affects: all
gotchaTypeScript types for helper methods like `findOneById` may not be exported in all versions; check TypeScript definitions.
fix
Upgrade to >=0.3.0 or cast return types manually.
affects: <0.3.0
gotchaThe `mysql` package is used directly without any promise-based wrapper – errors from `mysql` are not caught unless explicitly handled in query promises.
fix
Always wrap calls in try/catch or use .catch().
affects: all
Errors
Common errors & fixes
Error: connect must be called before query
Calling `query()` without first calling and awaiting `connect()`.
fix
Ensure `await connect(config)` is executed before any query or helper method.
TypeError: mysql.createConnection is not a function
Missing or incorrect version of `mysql` peer dependency (e.g., `mysql2` instead of `mysql`).
fix
Install correct peer dependency: `npm install mysql`.
Cannot find module 'mysql-kit'
Package not installed or TypeScript cannot resolve module.
fix
Run `npm install mysql mysql-kit` and ensure tsconfig has `"moduleResolution": "node"`.
Upgrade
Version history
0.3.0latest on npm
Audit
Dependencies
mysqlrequiredPeer dependency – the underlying MySQL driver; must be installed separately.
@types/mysqloptionalOptional dev dependency for TypeScript type definitions.
Agent activity
7 hits · last 30 days
node
6
Resources
mysql-kit — npm install mysql-kit · libregistry