Socket
Socket
Sign inDemoInstall

@evodev/evo.db

Package Overview
Dependencies
1
Maintainers
3
Versions
16
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @evodev/evo.db

A simple local storage database that automatically setup itself for you.


Version published
Maintainers
3
Created

Readme

Source

Evo.DB

Is a local storage database that is very easy to use.

Methods

DB(config, callback) To make new database.

  • config (JSON) Config of database.
    • folder (String) Path of database files.
  • callback (Function) Function that will fired if a document is corrupted.

DB#isExist(name) To check does a document is exist or no.

  • name (String) Name of the document.

DB#create(name) To create a document.

  • name (String) Name of document.

DB#delete(name) To delete a document.

  • name (String) Name of document.

DB#set(name, key, value) To set variable value from a document.

  • name (String) Name of document.
  • key (String) Name of variable.
  • value (String/Non Circular Object/JSON/Array/Number) New value of variable.

DB#add(name, key, value) To add value into variable value from a document.

  • name (String) Name of document.
  • key (String) Name of variable.
  • value (String/Non Circular Object/JSON/Array/Number) New value of variable.

DB#get(name, key) To get variable value from a document.

  • name (String) Name of document.
  • key (String) Name of variable.

DB#push(name, key, value) Push a value info key from a document.

  • name (String) Name of document.
  • key (String) Name of variable.
  • value (String/Non Circular Object/JSON/Array/Number) Item that want to get pushed to a variable.

DB#getKeys(name) Get all keys of document.

  • name (String) Name of document.

DB#getValues(name) Get all values of document.

  • name (String) Name of document.

DB#getEntries(name) Get entries of document.

  • name (String) Name of document.

DB#getAll(name) Get all variables of document.

  • name (String) Name of document.

DB#remove(name, key) (Beta) Remove a value of document by key.

  • name (String) Name of document.
  • key (String) Name of variable.

Example

let DB = require("@evodev/evo.db");
let db = new DB({
    folder: __dirname + "/"
}, (data) => {
    console.log(`Document ${data.document} is corrupted! Successfully fixed the document.`);
});

if (!db.isExist("test")) {
    db.create("test");

    console.log(`Cannot found document "test". Successfully to make it.`);
}

if (!db.get("test", "count")) {
    db.set("test", "count", 1);

    console.log(`Cannot found variable "count" in document "test". Successfully to make it.`);
} else {
    db.add("test", "count", 1);

    console.log(`Added 1 into "count"'s value in "test" document.`);
}

console.log(`Count: ${db.get("test", "count")}`);
console.log(`All keys of document "test": ${db.getKeys("test")}`);
console.log(`All values of document "test": ${db.getValues("test")}`);

if (db.get("test", "count") > 2) {
    db.remove("test", "count");
    db.delete("test");

    console.log(`Count reached 3! Deleted "test" document.`);
}

Developer

  • Gaia#7541

Support

  • Discord Server

Donation

  • PayPal: nekomaru76

Keywords

FAQs

Last updated on 31 Oct 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc