7.1.1 • Published 7 months ago

hypr.db v7.1.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
7 months ago

Hyper Database

  • Faster, Lightweight and Small Map-based advanced Database.

Installation

  • We recommend to use yarn.
yarn add hypr.db

ChangeLog

News

  • Updated README.
  • Removed 'autoWrite' option from Database.

Misc

  • Some improvements.

Fixes

  • Interface-import based bugs are fixed.

Usage

  • A simple example is given below.

Database

// ESM (ECMAScript) (TypeScript)
import Database, { BSONDriver, JSONDriver } from 'hypr.db';

// CJS (Common)
const Database = require('hypr.db');

// Create Database (JSON (Default Options))
const db = new Database();
// Create Database (JSON)
const db = new Database({ driver: new JSONDriver() }); // You can enter the driver options however you want.
// Create Database (BSON)
const db = new Database({ driver: new BSONDriver() }); // You can enter the driver options however you want.

// set & get & del & has & exists
db.set('MyCoolKey', 'MyCoolValue');
db.get('MyCoolKey');
db.del('MyCoolKey');
db.has('MyCoolKey');
db.exists('MyCoolKey'); // Same with has

// find+ & filter & each & map & every & some & search
db.find((value) => value === 'MyCoolValue');
db.findUpdate('MyNewCoolValue', (value) => value === 'MyCoolValue');
db.findDelete((value) => value === 'MyNewCoolValue');
db.filter((value) => value === 'MyNewCoolValue');
db.each((value, key) => typeof db.get(key) === typeof value);
db.map((value, key) => typeof value === 'number');
db.every((value) => value === 'MyCoolValue'),
db.some((value) => value === 'MyCoolValue');
db.search((value) => value === 'MyCoolValue');

// other
db.assign(otherDatabase, 'set'); // Argument 2 is optional.
db.concat([hdb1, hdb2, hdb3, hdb4], hdb3.options); // Argument 2 is optional.
db.type('MyCoolValue');

// array & json
db.json();
const array = db.array();
array.keys();
array.values();

// pull & push
db.push('MyCoolArray', 0, 1, 2);
db.pull('MyCoolArray', (value) => value === 1);

// math
db.math('hyprdb.downloads', '-', 500, true); // Argument 4 is optional.
db.add('hyprdb.downloads', 1); // Argument 2 and 3 is optional.
db.sub('hyprdb.downloads', 1); // Argument 2 and 3 is optional.

// static
Database.checkOptions(db.options); // Argument 1 is optional.

// version
Database.version

DatabaseManager

  • Note: This is experimental feature. Some features may not work.
// ESM (ECMAScript) (TypeScript)
import Database, { DatabaseManager } from 'hypr.db';

// CJS (Common)
const { Database, DatabaseManager } = require('hypr.db');

global.mgr = new DatabaseManager();

// Create Databases
const db = new Database();
const db2 = new Database();
const db3 = new Database();
const db4 = new Database();

mgr.set('economy', db);
mgr.set('utils', db2);
mgr.set('storage', db3);
mgr.set('cash', db4);

const getEconomyDatabase = mgr.find((value, key) => key === 'economy'); // Way 1
const getEconomyDatabase = mgr.get('economy'); // Way 2
getEconomyDatabase.set('cash', 50);

// All features same with Database. (Only some functions is removed.)
7.1.1

7 months ago

7.1.0

7 months ago

6.1.0

9 months ago

6.0.1

9 months ago

6.0.0

9 months ago

6.1.2

9 months ago

6.1.1

9 months ago

6.0.2

9 months ago

6.1.3

9 months ago

7.0.0

8 months ago

5.1.9

9 months ago

5.1.8

9 months ago

5.1.7

9 months ago

5.1.6

9 months ago

5.1.5

9 months ago

5.1.4

9 months ago

5.1.3

9 months ago

5.1.2

9 months ago

5.1.1

9 months ago

5.1.0

9 months ago

5.0.3

9 months ago

5.0.2

9 months ago

5.0.1

10 months ago

5.0.0

10 months ago

4.1.0

10 months ago

4.0.0

10 months ago

3.1.1

10 months ago

3.1.0

10 months ago

2.0.0

10 months ago

1.2.1

10 months ago

1.2.0

10 months ago

1.1.2

10 months ago

1.1.0

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago