An amazing and simple json database
npm i hyper-jdb
// Using Node.js `require()`
const hyperJDB = require('hyper-jdb');
// Using ES6 imports
import hyperJDB from 'hyper-jdb';
const database = new hyperJDB("users") // This will create the folder `databases` and the `users.json` fileSets a value into the database.
database.set("language", "english")
/*
    {
        "language": "english"
    }
*/
// You can use dots to specify a new property 
database.set("user1.name", "Álvaro")
/* 
    {
        "language": "english",
        "user1": {
            "name": "Álvaro"
        }
    }
*/Gets an existing key from the database. 
Returns the value of the given key.
/*
    {
        "user1": {
            "name": "Álvaro",
            "age": 16
        },
        "user2": {
            "name": "Juan",
            "age": 20
        }
    }
*/
database.get("user1.name") // "Álvaro"
database.get("user2.age") // 20Searches the given key. 
Returns true if it exists or false if not.
/*
    {
        "user1": {
            "name": "newalvaro9",
            "hobbies": ["Gym", "Coding]
        }
    }
*/
database.has("user1.hobbies") // true
database.has("user1.age") // falseDeletes an existing key from the database.
/*
    {
        "user1": {
            "name": "Álvaro",
            "age": 16,
            "hobbies": ["Gym", "Coding", "Cycling"]
        }
    }
*/
database.delete("user1.hobbies[1]") // Deletes Coding property as it is hobbies[1]
/*
    {
        "user1": {
            "name": "Álvaro",
            "age": 16,
            "hobbies": ["Gym", "Cycling"]
        }
    }
*/Pushes to the given array a new value. 
Returns the updated array.
/*
    {
        "user1": {
            "name": "Álvaro",
            "age": 16,
            "hobbies": ["Gym", "Coding", "Cycling"]
        }
    }
*/
database.push("user1.hobbies", "Climbing")
/*
    {
        "user1": {
            "name": "Álvaro",
            "age": 16,
            "hobbies": ["Gym", "Coding", "Cycling", "Climbing"]
        }
    }
*/Adds to the given key the quantity provided (must be a Number). 
Returns the updated key value.
/*
    {
        "user1": {
            "name": "Álvaro",
            "money": 430
        }
    }
*/
// Adds 150 to 430 money property
database.add("user1.money", 150) // 580
/*
    {
        "user1": {
            "name": "Álvaro",
            "money": 580
        }
    }
*/Substracts from the given key the quantity provided (must be a Number). 
Returns the updated key value.
/*
    {
        "user1": {
            "name": "Álvaro",
            "money": 430
        }
    }
*/
// Substracts 240 from 430 money 
database.add("user1.money", 240) // 190
/*
    {
        "user1": {
            "name": "Álvaro",
            "money": 190
        }
    }
*/Clears all the data in the .json file
database.drop() // Clears the database Have any doubts or suggestions?
Send me a private message on Discord: @newalvaro9
Copyright 2023, Álvaro Poblador