Registry / database / rik-db

rik-db

JSON →
library1.2.1jsnpmunverified

rik-db is a database ORM wrapper, currently at version 1.2.1. It provides a migration system with version 0.2.0.0 – Multicode. The package ships TypeScript types for better developer experience. It wraps common database operations and offers a migration workflow. Active development is indicated by ongoing releases. Key differentiators include its built-in migration tooling and TypeScript support out of the box, distinguishing it from simpler ORM wrappers.

npm install rik-db
INSTALL
IMPORT
SIG · RIK-DB
R
rik-db
databasejavascriptv1.2.1
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 'rik-db'
const Database = require('rik-db')
richt-db is ESM-only; require() will not work.
Migration
import { Migration } from 'rik-db/migration'
import { Migration } from 'rik-db'
Migration is exported from a subpath; the main package does not export it directly.
type DatabaseOptions
import type { DatabaseOptions } from 'rik-db'
TypeScript users should use type-only imports for types to avoid runtime overhead.

This example shows how to import Database, connect to a database, run a query, and disconnect using the rik-db ORM wrapper.

import { Database } from 'rik-db'; const db = new Database({ host: 'localhost', port: 5432, user: 'admin', password: process.env.DB_PASSWORD ?? '' }); async function main() { await db.connect(); const users = await db.query('SELECT * FROM users'); console.log(users); await db.close(); } main();
Debug
Known issues
breakingIn version 1.0.0, the Database constructor changed from accepting a connection string to an options object.
fix
Update constructor calls to use an options object: new Database({ host, port, user, password }) instead of new Database(connectionString).
affects: <1.0.0
breakingIn version 2.0.0 (future), query() will return an array of plain objects instead of custom row objects.
fix
Prepare to access properties directly on returned objects; stop relying on .get() methods.
affects: >=1.2.0 <2.0.0
gotchaThe .env file must define DB_PASSWORD variable; otherwise connection will fail without clear error.
fix
Always set DB_PASSWORD in environment or pass password option explicitly.
affects: >=1.0.0
deprecatedThe connect() method is deprecated in favor of implicit connection on first query.
fix
Remove explicit connect() calls; database will connect automatically on first query.
affects: >=1.2.0
Errors
Common errors & fixes
TypeError: (0 , _rikDb.Database) is not a constructor
Using require() with an ESM-only package.
fix
Switch to ES modules: replace require with import and ensure 'type': 'module' in package.json.
MigrationError: Migration version mismatch
Attempting to run migrations with incompatible migration scripts.
fix
Run the migration tool with the correct version flag: npx rik-db migrate --version 0.2.0.0
Error: getaddrinfo ENOTFOUND localhost
Database host 'localhost' is not resolvable.
fix
Ensure database server is running and host is spelled correctly. Use '127.0.0.1' if needed.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
16
Meta
1
Resources
packagerik-db
rik-db — npm install rik-db · libregistry