npm promulgates marsupials

    @evodev/evo.db

    3.1.0 • Public • Published

    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

    Donation

    • PayPal: nekomaru76

    Install

    npm i @evodev/evo.db

    DownloadsWeekly Downloads

    0

    Version

    3.1.0

    License

    ISC

    Unpacked Size

    9.99 kB

    Total Files

    4

    Last publish

    Collaborators

    • nekomaru76
    • akuankka128