0.2.1 • Published 2 years ago

suchdb v0.2.1

Weekly downloads
2
License
Apache-2.0
Repository
github
Last release
2 years ago

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'
//	}
// ]
0.1.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.0.1

7 years ago