All Projects → TomPrograms → Stormdb

TomPrograms / Stormdb

Licence: mit
🌩️ StormDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database for NodeJS, the browser or Electron.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Stormdb

Lowdb
Simple to use local JSON database (supports Node, Electron and the browser)
Stars: ✭ 16,886 (+4059.11%)
Mutual labels:  json, database, embedded-database, embeddable, localstorage
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+76.6%)
Mutual labels:  json, database, localstorage
Elastic
R client for the Elasticsearch HTTP API
Stars: ✭ 227 (-44.09%)
Mutual labels:  json, database
AloeDB
Light, Embeddable, NoSQL database for Deno 🦕
Stars: ✭ 111 (-72.66%)
Mutual labels:  embeddable, embedded-database
Lazer Database
PHP flat file database to store data with JSON
Stars: ✭ 254 (-37.44%)
Mutual labels:  json, database
Json Flatfile Datastore
Simple JSON flat file data store with support for typed and dynamic data.
Stars: ✭ 212 (-47.78%)
Mutual labels:  json, database
Scribble
A tiny Golang JSON database
Stars: ✭ 218 (-46.31%)
Mutual labels:  json, database
lapisdb
A modern, easy-to-use and feature-rich TypeScript embedded database.
Stars: ✭ 21 (-94.83%)
Mutual labels:  embeddable, embedded-database
Githubdb
A Lightweight Cloud based JSON Database with a MongoDB like API for Node.
Stars: ✭ 174 (-57.14%)
Mutual labels:  json, database
Node Json Db
A simple "database" that use JSON file for Node.JS.
Stars: ✭ 314 (-22.66%)
Mutual labels:  json, database
Anime Offline Database
Updated every week: A JSON based offline anime database containing the most important meta data as well as cross references to various anime sites such as MAL, ANIDB, ANILIST, KITSU and more...
Stars: ✭ 292 (-28.08%)
Mutual labels:  json, database
Deta database
Plsql Database数据库
Stars: ✭ 321 (-20.94%)
Mutual labels:  json, database
Barrel Platform
Distributed database for the modern world
Stars: ✭ 201 (-50.49%)
Mutual labels:  json, database
Autoserver
Create a full-featured REST/GraphQL API from a configuration file
Stars: ✭ 188 (-53.69%)
Mutual labels:  json, database
Web Database Analytics
Web scrapping and related analytics using Python tools
Stars: ✭ 175 (-56.9%)
Mutual labels:  json, database
sync-client
SyncProxy javascript client with support for all major embedded databases (IndexedDB, SQLite, WebSQL, LokiJS...)
Stars: ✭ 30 (-92.61%)
Mutual labels:  localstorage, embedded-database
Bigchaindb
Meet BigchainDB. The blockchain database.
Stars: ✭ 3,768 (+828.08%)
Mutual labels:  json, database
Radon
RadonDB is an open source, cloud-native MySQL database for building global, scalable cloud services
Stars: ✭ 1,584 (+290.15%)
Mutual labels:  json, database
Marklogic Data Hub
The MarkLogic Data Hub: documentation ==>
Stars: ✭ 113 (-72.17%)
Mutual labels:  json, database
Immortaldb
🔩 A relentless key-value store for the browser.
Stars: ✭ 2,962 (+629.56%)
Mutual labels:  database, localstorage
StormDB logo

🌩️ StormDB is a tiny, lightweight, 0 dependency, easy-to-use JSON-based database that allows users to quickly and easily achieve data persistence by provided an engine to store and access JSON data for NodeJS the browser or Electron.


Try it online now: Demo Page and Interactive Playground!

Example: Add a post entry under users.tom and save it to the database.

db.get("users")
  .get("tom")
  .push({ title: "Post 1" })
  .save();

Features

  • 🏎️ [Blazingly Fast Speeds] - Fast read and write speeds, even when handling large data.
  • 📦 Tiny Size - Tiny source code size allows for blazingly fast loading when speed matters.
  • ⚡️ Versatile - Can be used with NodeJS, in the browser or in Electron.

Usage

Install StormDB through NPM:

$ npm i stormdb

Basic usage with NodeJS:

const StormDB = require("stormdb");

// start db with "./db.stormdb" storage location
const engine = new StormDB.localFileEngine("./db.stormdb");
const db = new StormDB(engine);

// set default db value if db is empty
db.default({ users: [] });

// add new users entry
db.get("users").push({ name: "tom" });

// update username of first user
db.get("users")
  .get(0)
  .get("name")
  .set("jeff");

// save changes to db
db.save();

The db.stormdb database file is updated to:

{
  "users": [
    {"name":"jeff"}
  ]
}

Typescript Usage:

import StormDB from "stormdb";

// start db with "./db.stormdb" storage location
const engine = new StormDB.localFileEngine("./db.stormdb");
const db = new StormDB(engine);

StormDB is designed to be flexible, and can be used in NodeJS, the browser or even Electron with very small adaptations to the code. Examples usages can be seen below:

Engine API

For expanding functionality, each database initialized can be expanded with the following options, in the format new Engine(path, options);.

  • serialize - function to serialize data before writing it to the database.
  • deserialize - function to deserialize data from the database.

Database Operations Examples

Change Value of Key in Database:

db.get("old").set("newData");
// before: {"old": "oldData"}
// after: {"old": "newData"}

Return the Raw Value of a Selected Property:

// before {"list": [1, 2, 3]}
db.get("list").value(); // returns [1, 2, 3]

Set Key-Value Pair on Dictionary Property:

db.set("key", "value").save();
// before: {}
// after: {"key": "value"}

Delete Value:

db.delete("key");
// before: {'key': 'value', 'key2': 'value2'}
// after: {'key2': 'value2'}

Set Key-Value Pair on Dictionary with Shorthand Syntax:

db.set("key.key2", "value").save();
// before: {}
// after: {"key": {"key2": "value"}}

Set Default Data for Empty Database:

db.default({ name: "tom" });

// actual db: {}
console.log(db.get("name")); // prints "tom"

Push Item to Array Property:

db.get("list")
  .push(1)
  .save();

// before: {'list': []}
// after: {'list': [1]}

Filter Out All Elements under 5:

// before = {'list': [1,2,6,1]}
// output = {'list': [6]}

db.get("list").filter(i => i >= 5);

// save db
db.save();

Change Element with Highest Value:

// before = {'users': [{value: 10}, {value: 5}, {value: 6}]}
// after = {'users': [{value: "changed"}, {value: 6}, {value: 5}]}

db.get("users").sort((a, b) => b.value - a.value);

// change value of highest element
db.get("users")
  .get(0)
  .get("value")
  .set("changed");

// save db
db.save();

Map List, Squaring Each Number in List:

// before = {'data': [1,2,3,4,5]}
// after = {'data': [1,4,9,16,25]}

// square each number in the list
db.get("data").map(x => x ** 2);

// save db
db.save();

Reduce List, Finding Value of All Values in List Summed:

// before = {'data': [1,2,3,4,5]}
// after = {'data': 15}

// find value of all numbers in list summed together
db.get("data").reduce(
  (accumulator, currentValue) => accumulator + currentValue
);

// save db
db.save();

Leverage Serialize and Deserialize functions to encrypt and decrypt data:

const engine = new StormDB.localFileEngine("./db.stormdb", {
  serialize: data => {
    // encrypt and serialize data
    return encrypt(JSON.stringify(data));
  },
  deserialize: data => {
    // decrypt and deserialize data
    return JSON.parse(decrypt(data));
  }
});
const db = new StormDB(engine);

Credit

Author: Tom

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].