daclusta

1.1.0 • Public • Published

daclusta

Build Status David DM GitHub code size in bytes GitHub package.json version GitHub

An in memory/file based database that can run on multiple threads.

Installation

npm i --save daclusta

Usage

const db = require('daclusta').promises

async function example () {
  const connection = await db.connect('./db.json');

  const insertedRecord = await db.post(connection, {
    firstName: 'Joe',
    lastName: 'Bloggs
  });

  const readRecord = await db.get(connection, insertedRecord.meta.id);

  await db.close(connection);

  // readRecord.doc === { example: 1 }
}

example()

API

Method Arguments Description
Connection These methods control opening and closing database connections.
1.1 .connect filename Connect to a database. Will create if does not exist.
1.2 .close connection Close a connection.
Actions These methods allow operating on a connection
2.1 .get connection, id Get a record on a database by id.
2.2 .post connection, record Create a new record on a database.
2.3 .put connection, id, newRecord Replace an existing record with another on a database.
2.4 .patch connection, id, partialRecord, Set some properties on an existing record on a database.
2.5 .del connection, id Delete an existing record on a database.
2.6 .addListener connection, handler Listen to changes.
2.7 .removeListener connection, handler Stop listening to changes.

License

This project is licensed under the terms of the AGPL-3.0 license.

Readme

Keywords

none

Package Sidebar

Install

npm i daclusta

Weekly Downloads

1

Version

1.1.0

License

ISC

Unpacked Size

45.6 kB

Total Files

8

Last publish

Collaborators

  • markwylde