x51 // @kung-fu // moneta

x51@cyberspace:~$ man moneta

MONETA(3)@kung-fu Library Functions ManualMONETA(3)

name

moneta — a Node.js JSON store for lightweight database needs

synopsis

npm install @kung-fu/moneta
import { JSONStore, Pair } from '@kung-fu/moneta';

description

@kung-fu/moneta stores tables of key/value records in a single JSON file — a database for the many cases that don’t need one. The API is deliberately SQL-shaped (create, insert, select, update, delete, drop) without a server, a driver, or a schema. Writes accumulate in memory until an explicit commit() persists them to disk.

methods // JSONStore

methodreturnsdescription
constructor(opts?)storeopen or create a store; accepts a filename or a DBSettings object
create(table) / drop(table)storeadd or remove a table
exists(table)booleancheck whether a table exists
insert(table, key, value)ResultSetinsert a single record
insertAll(table, pairs)numberbulk insert an array of PairSet records
update(table, key, value)ResultSetreplace the value stored under a key
delete(table, key)ResultSetremove a record
select(table, criteria?)ResultSetfetch by key, or query with where / sort / limit criteria
commit()voidpersist pending changes to the JSON file

examples

Basic CRUD — nothing touches disk until the commit:

const db = new JSONStore('site.json');
      
      db.create('pages');
      db.insert('pages', 'page-1', { title: 'Home', content: 'Welcome' });
      db.update('pages', 'page-1', { title: 'Updated Home' });
      db.select('pages', 'page-1');
      db.commit();

Bulk insert with the Pair utility, which zips keys to values:

const data = [
          { title: 'Article 1', author: 'Alice' },
          { title: 'Article 2', author: 'Bob' }
      ];
      
      db.create('articles');
      db.insertAll('articles', Pair.asPairs([1, 2], data));
      db.commit();

Query with criteria instead of a key:

db.select('articles', { where: ['author', 'Alice'] });
      db.select('articles', { sort: ['author', 'ASC'] });
      db.select('articles', { sort: ['title', 'DESC'], limit: 10 });

see also

npmjs.com/package/@kung-fu/moneta, proto(3), minerva(1)

@kung-fu2026-06-04MONETA(3)

x51@cyberspace:~$ cd ~/@kung-fu