Registry / database / highsql

highsql

JSON →
library1.3.3jsnpmunverified

Highsql is a TypeScript module that provides a high-level MySQL database utility built on top of mysql2/promise. Version 1.3.3 offers a promise-based interface with connection pooling, prepared statements, and convenience methods for common operations (SELECT, INSERT, UPDATE, DELETE) and transactions. Unlike raw mysql2 usage, highsql simplifies query construction and error handling with custom error classes. The library targets TypeScript developers who need a readable, secure wrapper without an ORM. Active development is moderate; the package has low weekly downloads and no recent releases, suggesting a maintenance phase. Key differentiators: built-in transaction scope, getByID shorthand, and underlying pool access.

npm install highsql
INSTALL
IMPORT
SIG · HIGHSQL
H
highsql
databasejavascriptv1.3.3
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.

Connection
import { Connection } from 'highsql'
const Connection = require('highsql')
ESM-only; require() will fail. Types come with the package (.d.ts).
ConnectionConfig
import { ConnectionConfig } from 'highsql'
const { ConnectionConfig } = require('highsql')
Type for config object. Also ESM-only.
RowDataPacket
import { RowDataPacket } from 'highsql'
Import from 'mysql2' (unnecessary)
Re-exported from mysql2; type only.

Demonstrates creating a connection, basic CRUD operations, and a transaction with highsql.

import { Connection, ConnectionConfig } from 'highsql' async function main() { const config: ConnectionConfig = { host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASSWORD ?? '', database: 'test' } const conn = new Connection(config) const rows = await conn.select('users', 'id, name', 'id = ?', [1]) console.log(rows) await conn.insert('users', { name: 'Alice', email: 'alice@example.com' }) await conn.update('users', { email: 'alice@new.com' }, 'id = ?', [1]) await conn.delete('users', 'id = ?', [1]) await conn.transaction(async (tx) => { await tx.insert('orders', { user_id: 1, total: 100 }) await tx.update('users', { balance: 900 }, 'id = ?', [1]) }) await conn.close() } main().catch(console.error)
Debug
Known issues
gotchaThe Connection constructor expects a plain object; ensure all required fields (host, user, password, database) are provided. Missing fields may cause silent failures or pool errors.
fix
Always validate config object completeness before instantiation.
affects: >=1.0
deprecatedThe getPool() method returns the underlying mysql2 Pool, but note that highsql's own methods use it internally; closing the pool via pool.end() directly can break highsql's state.
fix
Use conn.close() instead of manually closing the pool.
affects: >=1.0
gotchaThe `transaction` method requires a callback that returns a Promise; if you forget to return the promise chain, the transaction may commit prematurely.
fix
Ensure your callback is async or returns a promise: async (conn) => { ... }
affects: >=1.0
gotchaThe `select` method returns RowDataPacket[]; if no rows match, it returns an empty array, not null. Check array length before accessing elements.
fix
Use rows.length === 0 to detect empty result.
affects: >=1.0
Errors
Common errors & fixes
TypeError: ConnectionConfig is not a constructor
Using `new ConnectionConfig()` as if it were a constructor; ConnectionConfig is an interface/type, not a class.
fix
Instead, create a plain object: const config: ConnectionConfig = { host: '...', user: '...', password: '...', database: '...' }
Cannot find name 'Connection'. Did you mean 'mysql2'?
Missing import or incorrect path; highsql is installed but not imported.
fix
Ensure you have run `npm install highsql mysql2` and added `import { Connection } from 'highsql'`.
Error: Cannot find module 'highsql'
highsql is not installed, or you are using a path instead of package name.
fix
Run `npm install highsql` and check your import path: `import { Connection } from 'highsql'`
Upgrade
Version history
1.3.3latest on npm
Audit
Dependencies
mysql2requiredCore database driver; highsql wraps mysql2's promise API and expects it to be installed separately.
Agent activity
10 hits · last 30 days
node
10
Resources
highsql — npm install highsql · libregistry