Registry / database / jssql
library1.5.12jsnpmunverified

A simple JavaScript MySQL library for Node.js that provides an object-oriented API to perform CRUD operations without writing raw SQL. Version 1.5.12 is the latest stable release with low release cadence (last updated years ago). Differentiates by using Scheme/Table classes with structure constants for type safety, pool connection support, and optional read-only replica configuration. Suitable for small projects or prototypes but lacks modern features like promises, TypeScript types, or migration management.

npm install jssql
INSTALL
IMPORT
SIG · JSSQL
J
jssql
databasejavascriptv1.5.12
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.

Database
const { Database } = require('jssql');
import { Database } from 'jssql';
Package uses CommonJS; ESM import not supported.
Scheme
const { Scheme } = require('jssql');
const Scheme = require('jssql').Scheme;
Destructuring is preferred for clarity.
Table
const { Table } = require('jssql');
var jssql = require('jssql'); var Table = jssql.Table;
Old-style assignment works but destructuring is cleaner.

Initializes a MySQL database using JSSQL with connection pooling, creates a table scheme, and performs an insert followed by a findOne query.

const { Database, Scheme, Table, Structure } = require('jssql'); const db = new Database({ host: process.env.DB_HOST ?? '127.0.0.1', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: 'TEST_DATABASE', connectionLimit: 10 }); const scheme = new Scheme({ ID: { type: Structure.Type.INT, AI: true, Index: Structure.Index.PRIMARY }, NAME: { type: 'VARCHAR', length: 100 } }); const table = new Table('users', scheme); db.table(table); table.save({ NAME: 'Alice' }, (err) => { if (err) throw err; table.findOne({ NAME: 'Alice' }, (err, row) => { if (err) throw err; console.log(row); }); });
Debug
Known issues
gotchaAfter calling save(), the row may not be immediately available for find queries. A small timing window exists.
fix
Use a callback or setTimeout before calling find after save, or consider using a different library with promise support.
affects: *
deprecatedPackage has not been updated in several years; uses callback-style APIs with no Promise support.
fix
Wrap callbacks in promises manually or migrate to a modern MySQL library like mysql2 or knex.
affects: *
gotchaThe 'mysql' driver version is pinned and may have known vulnerabilities. No active maintenance for security patches.
fix
Audit your dependency tree and consider replacing jssql to avoid supply chain risks.
affects: *
Errors
Common errors & fixes
Cannot find module 'jssql'
Package not installed
fix
Run 'npm install jssql' in your project directory.
TypeError: Database is not a constructor
Wrong import style: default import vs named import
fix
Use 'const { Database } = require('jssql');' instead of 'const Database = require('jssql');'
Error: ER_ACCESS_DENIED_ERROR: Access denied for user 'root'@'localhost'
Invalid database credentials
fix
Check your host, user, password, and database name in the Database constructor.
Upgrade
Version history
1.5.12latest on npm
Audit
Dependencies
mysqlrequiredUnderlying MySQL driver
Agent activity
8 hits · last 30 days
node
6
Resources
packagejssql
jssql — npm install jssql · libregistry