Skip to content

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

License

Notifications You must be signed in to change notification settings

markwylde/daclusta

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

daclusta

Build Status Known Vulnerabilities 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.

About

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

Resources

License

Stars

Watchers

Forks