Registry / database / ts-mysql-helper

ts-mysql-helper

JSON →
library1.3.2jsnpmunverified

A TypeScript MySQL helper library (v1.3.2) that wraps the mysql driver with a singleton pattern for managing multiple database connections. Provides simplified CRUD operations (select, insert, update, delete) with support for complex queries (range, ordering). Released sparsely, last update in 2020. Limited differentiation: offers a basic abstraction over raw SQL but lacks high-level ORM features. Not recommended for new projects.

npm install ts-mysql-helper
INSTALL
IMPORT
SIG · TS-MYSQL-HELPER
T
ts-mysql-helper
databasejavascriptv1.3.2
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.

MysqlHelper
import { MysqlHelper } from 'ts-mysql-helper'
import MysqlHelper from 'ts-mysql-helper'
Use named import; default import does not exist.
MysqlHelper.getInstance
const helper = MysqlHelper.getInstance(config)
new MysqlHelper(config)
Singleton pattern; use getInstance() instead of constructor.
MysqlConfig
import { MysqlConfig } from 'ts-mysql-helper'
const config: MysqlConfig = { ... }
Type imported for config objects; not needed in JS.

Initializes MysqlHelper with a MySQL config and performs a simple select query.

import { MysqlHelper } from 'ts-mysql-helper'; const config = { host: 'localhost', port: 3306, database: 'test', user: 'root', password: process.env.DB_PASSWORD ?? '', charset: 'utf8mb4' }; const helper = MysqlHelper.getInstance(config); async function main() { try { const rows = await helper.select('user', ['name', 'age'], { id: 1 }); console.log(rows); } catch (err) { console.error(err); } } main();
Debug
Known issues
gotchaMysqlHelper is a singleton; getInstance must be called without 'new'. The library does not export a class constructor for direct instantiation.
fix
Use MysqlHelper.getInstance(config) instead of new MysqlHelper(config).
affects: >=0.0.0
deprecatedThe library has not been updated since 2020 and the underlying mysql driver may have vulnerabilities. Consider migrating to mysql2 or an ORM.
fix
Migrate to mysql2 or use a maintained ORM like TypeORM or Prisma.
affects: >=0.0.0
gotchaError handling: many methods only log errors via console.log in the callback. Unhandled promise rejections may occur if errors are not caught in async functions.
fix
Wrap async calls in try/catch or attach .catch() to promises.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: MysqlHelper is not a constructor
Using 'new' on a singleton class that does not export a constructor.
fix
Use MysqlHelper.getInstance(config) instead of new MysqlHelper(config).
Error: Cannot find module 'ts-mysql-helper' or its corresponding type declarations
Missing TypeScript type definitions in the package (no @types/ts-mysql-helper).
fix
Install the package and ensure tsconfig.json includes 'skipLibCheck' or add a custom declaration file.
Upgrade
Version history
1.3.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
23 hits · last 30 days
node
20
Meta
1
OpenAI (training)
1
Resources