tiny-js-db
A tiny and fast in memory database with relationships support focused in simplicity, small footprint and lib size (for browser and node js)
What it is?
Tiny-js-db was born from a need for working with large relational data in memory where each byte of memory saved matters, GC must works masterfully and indexes are essential for performance... all with the smallest footprint and boilerplate possible.
Installation
There are 3 ways to install tiny-js-db:
Local file in your project:
Download the file tiny-js-db.min.js, add it to your project folder and add a script tag into your html or js file:
Hosted in a CDN:
Just add a script tag pointing to a CDN :
Install as a npm dependency:
npm install tiny-js-db --save
Usage Example
const TinyJsDb = ; // create a new database instanceconst Db = ; // create tablesconst heroes = Db;const abilities = Db; // set relationshipsDb; // add records to the databaseheroes;heroes;// add record and get its instanceconst ironMan = heroes; abilities;abilities;abilities;abilities; // retrieve a record by filterconst thor = heroes;// retrieve a record by idconst thunder = abilities; // add a relation between records - using its instancesheroes; // add a relation between records - using its idsheroes; // relations can be set from both sidesabilities; // get a record with its relationshipsconst item = heroes;console;/*{ _id: 1, name: 'Hulk', age: 40, abilities: [ { type: 'Resistance', _id: 1 }, { type: 'Super force', _id: 0 } ]}*/ const myHeroes = heroes;console;/*[ { name: 'Thor', age: 437, _id: 0 }, { name: 'Hulk', age: 40, _id: 1 }, { name: 'Iron Man', age: 42, _id: 2 }]*/
API Documentation
Click here to view a detailed API documentation:
tiny-js-db API Documentation
Important
IMPORTANT: This project is in the early stages of development, so I suggest not use this library in a production or serious project/product. The first stable version will be released soon, including basic documentation and usage examples (in this readme)
Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. One point that is very easy to contribute is chose a function, do some benchmarking and change the code to accomplish the most performance possible.
Please make sure to update tests as appropriate.
Modules / Thanks!
module | description |
---|---|
lodash/fp | Great library that provides many useful functionalities to deal with arrays, objects, collections, etc. use |
for now, lodash/fp is the only external dependency in this project.
License
MIT. Copyright (c) Herminio Brustulim.