Registry / database / chaos-database

chaos-database

JSON →
library19.0.2jsnpmunverified

Chaos ORM base classes for SQL adapters, version 19.0.2. Provides core abstractions for relational database operations including schema migration, query building, and result mapping. Integrates with Chaos ORM ecosystem for ActiveRecord or DataMapper patterns. Requires babel-polyfill as a peer dependency. Supports MySQL, PostgreSQL, SQLite through adapter packages. Release cadence is irregular; major version jumps indicate breaking changes. Differentiator from Sequelize/Knex: tighter integration with Chaos ORM's event-driven architecture.

npm install chaos-database
INSTALL
IMPORT
SIG · CHAOS-DATABASE
C
chaos-database
databasejavascriptv19.0.2
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
import { Database } from 'chaos-database'
import Database from 'chaos-database'
Default export does not exist; must use named import.
Source
import { Source } from 'chaos-database'
const Source = require('chaos-database').Source
CommonJS require works but named import is preferred for ESM.
Schema
import { Schema } from 'chaos-database'
import { Schema } from 'chaos'
Schema is not part of the root 'chaos' package; must use 'chaos-database'.

Shows instantiating a Database with a MySQL adapter, connecting, and running a raw query.

import { Database } from 'chaos-database'; import { MySQLAdapter } from 'chaos-mysql'; // or other adapter const db = new Database({ adapter: new MySQLAdapter({ host: process.env.DB_HOST ?? 'localhost', user: process.env.DB_USER ?? 'root', password: process.env.DB_PASS ?? '', database: process.env.DB_NAME ?? 'test' }) }); await db.connect(); const result = await db.query('SELECT 1 AS value'); console.log(result);
Debug
Known issues
deprecatedThe `setAdapter` method is deprecated in favor of passing adapter in constructor.
fix
Pass adapter directly to Database constructor instead of calling setAdapter() after instantiation.
affects: >=15.0
breakingIn v19, the `Schema` class no longer auto-migrates; manual migration required.
fix
Use Schema.migrate() explicitly to apply changes.
affects: >=19.0
gotchaThe `Database` constructor expects an adapter object, not a connection string.
fix
Create an adapter instance (e.g., from 'chaos-mysql') and pass it to the constructor.
affects: >=1.0
gotchababel-polyfill must be installed as a peer dependency for older Node versions.
fix
Install babel-polyfill alongside chaos-database.
affects: <20.0
Errors
Common errors & fixes
TypeError: Database is not a constructor
Importing default export instead of named export.
fix
Use import { Database } from 'chaos-database' instead of import Database from 'chaos-database'.
Error: Adapter not provided
Instantiating Database without an adapter.
fix
Pass an adapter instance to the Database constructor.
Upgrade
Version history
19.0.2latest on npm
Audit
Dependencies
babel-polyfillrequiredRequired as peer dependency for ES6+ features
Agent activity
13 hits · last 30 days
node
10
OpenAI (training)
1
Resources
chaos-database — npm install chaos-database · libregistry