An in memory/file based database that can run on multiple threads.
npm i --save daclusta
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()
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. |
This project is licensed under the terms of the AGPL-3.0 license.