Registry / database / jweb-mysql

jweb-mysql

JSON →
library0.4.4jsnpmunverified

MySQL DAO implementation for the jweb framework, version 0.4.4 (latest). Provides a lightweight data access layer for MySQL using the mysql npm client. Built with TypeScript types included. Release cadence unknown; likely infrequent updates. Differentiator: tightly integrated with jweb, offering a minimal DAO pattern. Alternatives: Sequelize, TypeORM, Knex for more features.

npm install jweb-mysql
INSTALL
IMPORT
SIG · JWEB-MYSQL
J
jweb-mysql
databasejavascriptv0.4.4
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
import { default as jwebMysql } from 'jweb-mysql';
import jwebMysql from 'jweb-mysql';
The package does not have a default export; use named import with default.
MysqlDao
import { MysqlDao } from 'jweb-mysql';
Main DAO class for MySQL operations.
MysqlConfig
import { MysqlConfig } from 'jweb-mysql';
Type interface for MySQL configuration.
CommonJS require
const { MysqlDao } = require('jweb-mysql');
Works with CommonJS require pattern.

Creates a MysqlDao instance using environment variables for connection, executes a simple SELECT query, and properly closes the connection.

import { MysqlDao } from 'jweb-mysql'; const dao = new MysqlDao({ host: process.env.MYSQL_HOST ?? 'localhost', port: parseInt(process.env.MYSQL_PORT ?? '3306', 10), user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DB ?? 'test', }); async function run() { try { const rows = await dao.query('SELECT ? AS result', [1]); console.log(rows); } catch (err) { console.error(err); } finally { dao.close(); } } run();
Debug
Known issues
gotchaThe 'mysql' package used internally has been unmaintained since 2021; consider using mysql2 for better performance and modern features.
fix
Switch to mysql2-based alternative or manually upgrade to mysql2 if possible.
affects: >=0.0.0
gotchaConnection pooling is not built-in; each MysqlDao instance creates its own connection. For high concurrency, manage connections externally.
fix
Use a connection pool (e.g., from mysql2) and pass individual connections to the DAO.
affects: >=0.0.0
gotchaThe 'query' method returns raw rows as plain objects without mapping to entity classes.
fix
Manually map results to desired types or use an ORM for automatic mapping.
affects: >=0.0.0
Errors
Common errors & fixes
Error: Cannot find module 'jweb-mysql'
Package not installed or not in node_modules.
fix
Run 'npm install jweb-mysql'.
TypeError: dao.query is not a function
Using an older version where 'query' might not exist or import is wrong.
fix
Ensure you are using the correct named import: import { MysqlDao } from 'jweb-mysql'.
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'user'@'host'
MySQL authentication credentials are incorrect.
fix
Check environment variables MYSQL_USER, MYSQL_PASSWORD and ensure they match MySQL user.
Upgrade
Version history
0.4.4latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL client driver for Node.js
Agent activity
5 hits · last 30 days
node
4
Resources
jweb-mysql — npm install jweb-mysql · libregistry