Registry / database / advanced-mysql

advanced-mysql

JSON →
library1.2.0jsnpmunverified

A Node.js module for simplifying MySQL database interactions with a query builder interface. Version 1.2.0 offers promise-based methods like aselect for building SELECT queries with join support, and a raw query method. It wraps the mysql2 package and provides a simple API for managing connections and executing queries. Ships TypeScript definitions. Key differentiators include a fluent join syntax and support for environment variable configuration.

npm install advanced-mysql
INSTALL
IMPORT
SIG · ADVANCED-MYSQL
A
advanced-mysql
databasejavascriptv1.2.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.

ASQL
import ASQL from 'advanced-mysql';
const ASQL = require('advanced-mysql');
Default ES module export. CommonJS require also works but is not recommended.
ASQL (named import)
import { ASQL } from 'advanced-mysql';
import { AdvancedMySQL } from 'advanced-mysql';
Named export is the same as default. Avoid misspelling.
type ASQL (TypeScript)
import type ASQL from 'advanced-mysql';
import { ASQL } from 'advanced-mysql'; (when only type needed)
TypeScript users can use import type for type-only usage.

Creates a connection, performs a SELECT query with a JOIN using the ASQL query builder, and logs the result.

import ASQL from 'advanced-mysql'; const db = new ASQL('localhost', 'root', '', 'test'); await db.createConnection(); const data = await db.aselect({ selects: ['username, profiles.profile_description'], table: 'users', joins: { profiles: { selfKey: 'id', table: 'users', foreignKey: 'user_profile' } } }); console.log(data); await db.closeConnection();
Debug
Known issues
gotchaThe aselect method requires a 'selects' key; using 'select' will fail silently.
fix
Use 'selects' instead of 'select'.
affects: >=0.0.0
gotchaEnvironment variable keys are DB_NAME, FSQL_HOST, etc., not standard DB_HOST.
fix
Set environment variables as per documentation: DB_NAME, FSQL_HOST, FSQL_USER, FSQL_PASSWORD.
affects: >=0.0.0
gotchacreateConnection() must be called before any query methods.
fix
Call await db.createConnection() after instantiation.
affects: >=0.0.0
gotchaPassword misspelled as 'passwrod' in docs; ensure correct spelling in code.
fix
Use correct spelling 'password' in constructor arguments.
affects: >=0.0.0
gotchaClose connection with 'closeConnection()' not 'end()' or 'close()'.
fix
Use db.closeConnection() to properly close the connection.
affects: >=0.0.0
Errors
Common errors & fixes
TypeError: db.createConnection is not a function
Forgot to instantiate the class or used a static method incorrectly.
fix
const db = new ASQL(...); await db.createConnection();
Error: Cannot find module 'advanced-mysql'
Package not installed or wrong import path.
fix
npm install advanced-mysql
TypeError: Cannot read properties of undefined (reading 'then')
Not awaiting the async method or misusing promises.
fix
Use await before async calls, e.g., const data = await db.aselect(...);
Upgrade
Version history
1.2.0latest on npm
Audit
Dependencies
mysql2requiredUnderlying MySQL driver for database connections and queries
Agent activity
35 hits · last 30 days
node
30
OpenAI (training)
1
Resources
advanced-mysql — npm install advanced-mysql · libregistry