suchdb

0.2.1 • Public • Published

SuchDB

  • Real-time JS database, fully loaded into memory.

!Proof of work, not for commercial use!

!In case of use, please perform all record validation yourself, before insertion in tables.

Install:

npm install suchdb

Basic use:

Insert

const { Database } = require('suchdb');
...
// Create Database.
const db = new Database('real_time_db')

// Create table.
const table = db.createTable('transactions');

// Insert record:
const data = {
	'amount': 90,
	'currency': 'Euro',
	'sender': 'John Appleseed',
	'receiver': 'Steve Props'
};
db.insert('transactions', data);
// or
table.insert(data);

Find

const result = db.findById('transactions', '<uuid>');
// Result (considering data in previous example)
// [
// 	{
//		'id': <uuid>,
//		'amount': 90,
//		'currency': 'Euro',
//		'sender': 'John Appleseed',
//		'receiver': 'Steve Props'
//	}
// ]

Select first or last row

const firstRow = db.selectFirstRow('transactions');
const lastRow = db.selectLastRow('transactions');

Delete

// (considering data in previous example)
db.deleteById('transactions', '<uuid>');

Query usage:

const { Query } = require('suchdb');
...
// Create query object (Notice, that you don't need "new" keyword).
const query = Query().where('amount', '>=', 89).first(10);

// Perform rows selection.
const rows = db.select('transactions', query);
// Result (considering data in previous example)
// [
// 	{
//		'id': <uuid>,
//		'amount': 90,
//		'currency': 'Euro',
//		'sender': 'John Appleseed',
//		'receiver': 'Steve Props'
//	}
// ]

Package Sidebar

Install

npm i suchdb

Weekly Downloads

6

Version

0.2.1

License

Apache-2.0

Unpacked Size

22.2 kB

Total Files

9

Last publish

Collaborators

  • markkhramko