Registry / database / jsite-database

jsite-database

JSON →
library6.1.0jsnpmunverified

Database module for the JSite package, providing a structured database interface with built-in auditing (SCD Type 4 row-based and column-based change tracking), SQL formatting via sql-formatter, SQL generation via json-sql-builder2, and MySQL support via the mysql module. Version 6.1.0 is the latest stable release. Key differentiators include integrated audit trail capabilities and customizable configuration for format, SQL dialect, and MySQL connection.

npm install jsite-database
INSTALL
IMPORT
SIG · JSITE-DATABASE
J
jsite-database
databasejavascriptv6.1.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.

JSiteDatabase
const JSiteDatabase = require('jsite-database')
import JSiteDatabase from 'jsite-database'
This package uses CommonJS and does not provide ESM exports.
JSiteDatabase
const { JSiteDatabase } = require('jsite-database')
const JSiteDatabase = require('jsite-database').default
Named export, not default export.
JSiteDatabase
const Database = new JSiteDatabase(options)
const db = JSiteDatabase(options)
JSiteDatabase is a constructor, must be instantiated with new.

Initializes a JSiteDatabase instance with MySQL connection and row-based auditing, then waits for readiness via ready().

const path = require('path'); const JSiteDatabase = require('jsite-database'); const db = new JSiteDatabase({ format: { indent: ' ' }, mysql: { host: process.env.MYSQL_HOST ?? 'localhost', user: process.env.MYSQL_USER ?? 'root', password: process.env.MYSQL_PASSWORD ?? '', database: process.env.MYSQL_DATABASE ?? 'test' }, sql: { language: 'mysql', options: { quoteIdentifiers: true } }, audit: 'row', files: { db: path.join(__dirname, 'private', 'mysql') } }); db.ready() .then(() => console.log('Database ready')) .catch(err => console.error(err));
Debug
Known issues
breakingIn version 6.x, the audit option 'row' and 'column' changed behavior. Ensure you review the new SCD implementation.
fix
Review auditing documentation and migrate your schema accordingly.
affects: 6.0.0 - 6.1.0
gotchaThe package uses 'json-sql-builder2' which has a different API than 'json-sql-builder'. Ensure you have the correct version.
fix
Use 'json-sql-builder2' as a dependency.
affects: >=5.0.0
deprecatedThe 'mysql' package used for MySQL connections is deprecated since version 6.0.0. Consider migrating to 'mysql2'.
fix
Replace 'mysql' with 'mysql2' in options or use a compatible wrapper.
affects: >=6.0.0
gotchaJSiteDatabase must be instantiated with 'new'. Calling it as a regular function will throw an error.
fix
Always use 'new JSiteDatabase(options)'.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Cannot find module 'jsite-database'
Package not installed in node_modules
fix
Run 'npm install jsite-database' in your project directory.
TypeError: JSiteDatabase is not a constructor
Using default import or calling function without 'new'
fix
Use 'const JSiteDatabase = require('jsite-database')' and instantiate with 'new JSiteDatabase()'.
Error: connect ECONNREFUSED 127.0.0.1:3306
MySQL server not running or incorrect host/port
fix
Ensure MySQL is running on localhost:3306, or provide correct host and port in options.
Error: Unknown audit method: 'all'
Passing invalid audit option
fix
Use one of 'row', 'column', or omit for default 'row'.
Upgrade
Version history
6.1.0latest on npm
Audit
Dependencies
mysqloptionalRequired for MySQL database connections
sql-formatteroptionalUsed for formatting SQL queries
json-sql-builder2optionalUsed for building SQL queries from JSON
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
jsite-database — npm install jsite-database · libregistry