npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

tiny-js-db

v1.0.5

Published

A tiny and fast in memory database with relationships support focused in simplicity, small footprint and lib size

Downloads

23

Readme

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:

<script src="tiny-js-db.min.js"></script>

Hosted in a CDN:

Just add a script tag pointing to a CDN :

<script src="https://cdn.jsdelivr.net/npm/tiny-js-db@latest/tiny-js-db.min.js"></script>

Install as a npm dependency:

npm install tiny-js-db --save

Usage Example

const TinyJsDb = require("./");

// create a new database instance
const Db = new TinyJsDb();

// create tables
const heroes = Db.createTable("heroes");
const abilities = Db.createTable("abilities");

// set relationships
Db.createRelationship(heroes, abilities);

// add records to the database
heroes.insert({ name: "Thor", age: 437 });
heroes.insert({ name: "Hulk", age: 40 });
// add record and get its instance
const ironMan = heroes.insert({ name: "Iron Man", age: 42 });

abilities.insert({ type: "Super force" });
abilities.insert({ type: "Resistance" });
abilities.insert({ type: "Money" });
abilities.insert({ type: "Thunder" });

// retrieve a record by filter
const thor = heroes.getFirst({ name: "Thor" });
// retrieve a record by id
const thunder = abilities.getById(3);

// add a relation between records - using its instances
heroes.addRelation(thor, "abilities", thunder);

// add a relation between records - using its ids
heroes.addRelation(1, "heroes", 1);

// relations can be set from both sides
abilities.addRelation(2, "abilities", ironMan);

// get a record with its relationships
const item = heroes.getById(1, ["abilities"]);
console.log(item);
/*
{
  _id: 1,
  name: 'Hulk',
  age: 40,
  abilities: [ { type: 'Resistance', _id: 1 }, { type: 'Super force', _id: 0 } ]
}
*/

const myHeroes = heroes.getAll();
console.log(myHeroes);
/*
[
  { 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.