Skip to content

NoName-txt/all.db

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 

Repository files navigation

all.db

If you found a bug contact me on Discord.

Set
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

// Sets a data in the database
db.set("nonametxt.test", "all.db");

Output:

{
  "nonametxt":{
    "test":"all.db"
  }
}

Get
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//Fetches you the data
db.get("nonametxt");
db.fetch("nonametxt");

Output:

"all.db"

Delete
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//Deletes data
db.delete("nonametxt.test");
db.remove("nonametxt.test");

Output:

{}

Add
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//If the data is a number, it adds a certain amount to data
db.add("nonametxt.number", 1);

Output:

data + 1

Subtract
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//If the data is a number, it subtracts a certain amount from it
db.subtract("nonametxt.number", 1);

Output:

data - 1

Push
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });
db.push("nonametxt.array", { name: "NoNametxt" });

//Pushes an element to an array
db.push("nonametxt.array", { name: "NoNametxt" }, true); //If data is not an array It will convert the data to an array

Output:

{
  "nonametxt":{
    "array":[
      {
        "name":"NoNametxt"
      }
    ]
  }
}

Pull
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//Specify the object you want to delete.
db.pull("nonametxt.array", (value) => {
  try{
    return value[1].name == "NoNametxt";
  }catch(error){

  }
});

Output:

{
  "nonametxt":{
    "array":[]
  }
}

Data Exists
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//Checks the data is available
db.exists("nonametxt.test");
db.has("nonametxt.test");

Output:

true or false

Typeof
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//Shows the type of data
db.typeof("nonametxt.typeof"); // true or false (checks the string)

//Compares the type of data with the type you typed
db.typeof("nonametxt.typeof", "number");

Output:

true or false

Math
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//If the data is a number, applies math operations to data.
db.math("nonametxt", "*", 10);

Output:

data * 10

Find
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//If you have entered data, it will find and show you.
db.find("Database", true); //Searches without checking case

Database:

{
  "string": "DATABASE",
  "otherString": "NoNametxt",
  "object": {
    "db": "database"
  },
  "array": ["database"]
}

Output:

[
  [ "string", "DATABASE" ],
  [ "object.db", "database" ],
  [ "array.0", "database" ]
]

Filter
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

//If you have entered data, it will filter and show you.
db.filter(([key, value]) => {
    try {
      return value.includes("DataBase");
    } catch (error){

    };
});

Database:

{
  "string": "DataBase",
  "otherString": "NoNametxt",
  "object": {
    "db": "DataBase"
  },
  "array": [ "DataBase" ]
}

Output:

{ 
  "string": "DataBase",
  "array": [ "DataBase" ] 
}

Get All
const alldb = require("all.db");
const db = new alldb.Database({ dataPath: "./data.json" });

db.getAll(); //Returns JSON Data

db.getAll().save(path); //Saves the data to the specified path

Output:

{ All Data }

Version 0.2.8 *

+ subtract Fixed

Thx for use all.db.

About

Simple, Fast, JSON Database

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published