Registry / database / node-json-database

node-json-database

JSON →
library0.0.34jsnpmunverified

A simple JSON-based database management system for Node.js that stores data in flat JSON files. Version 0.0.34 is the latest stable release, with infrequent updates. It provides SQL-like operations (create, insert, where) but lacks advanced features like indexing, transactions, or concurrency control. Differentiates from full DBMS by being lightweight and file-based, suitable for prototyping or small projects. Not intended for production use.

npm install node-json-database
INSTALL
IMPORT
SIG · NODE-JSON-DATABASE
N
node-json-database
databasejavascriptv0.0.34
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.

db
import { db } from 'node-json-database'
const db = require('node-json-database')
ESM-only since outset; CommonJS require will return undefined.
Database
import { db } from 'node-json-database'
import { Database } from 'node-json-database'
The package exports a function `db`, not a class. No named export 'Database'.
myDB.table()
const table = myDB.table('name'); table.create()
myDB.createTable('name')
Use `myDB.table('name')` to get a table reference, then call `.create()`.

Creates a database, table with columns, inserts records, and queries with where filter.

import { db } from 'node-json-database'; // Create database const myDB = db('myDB'); myDB.create(); // Create table const friendsTable = myDB.table('friends'); friendsTable.create(); // Add columns friendsTable.columns.add([ { name: 'firstName', dataType: 'String' }, { name: 'lastName', dataType: 'String' }, { name: 'birthday', dataType: 'DateTime' }, { name: 'favouriteNumber', dataType: 'Int' } ]); // Insert values friendsTable.insert([ { firstName: 'John', lastName: 'Doe', birthday: new Date('01 Jan 1970').getTime(), favouriteNumber: 42 }, { firstName: 'Johnny', lastName: 'Doe', birthday: new Date('01 Jan 2000').getTime(), favouriteNumber: 69 } ]); // Query const search = friendsTable.get().where(row => row.firstName == 'Johnny'); console.log(search.rows);
Debug
Known issues
gotchaDatabase files are stored in a local directory; no server or concurrent access support.
fix
Use only in single-process, non-concurrent environments.
affects: >=0.0.1
gotchaThe `db()` function creates database directories relative to process.cwd().
fix
Ensure correct working directory or provide absolute path.
affects: >=0.0.1
gotchaTable must be created before adding columns or inserting data; no schema migration.
fix
Always call `table.create()` before using it.
affects: >=0.0.1
gotchaData types are enforced at insert time; invalid types may cause silent failures.
fix
Ensure inserted data matches column types exactly.
affects: >=0.0.1
Errors
Common errors & fixes
TypeError: db is not a function
Using CommonJS require instead of ESM import
fix
Use `import { db } from 'node-json-database'`
Cannot find module 'node-json-database'
Package not installed or import path typo
fix
Run `npm install node-json-database` and verify import string
TypeError: myDB.table is not a function
Calling table() on undefined (db not created)
fix
Ensure `myDB = db('myDB'); myDB.create();` before using table()
Upgrade
Version history
0.0.34latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
node-json-database — npm install node-json-database · libregistry