If you found a bug contact me on Discord.
Set
import { Database } from "all.db";
const db = new Database({ dataPath: "./data.json" });
// Sets a data in the database
db.set("nonametxt.test", "all.db");
Output:
{
"nonametxt":{
"test":"all.db"
}
}
Get
import { Database } from "all.db";
const db = new Database({ dataPath: "./data.json" });
//Fetches you the data
db.get("nonametxt");
db.fetch("nonametxt");
Output:
"all.db"
Delete
import { Database } from "all.db";
const db = new Database({ dataPath: "./data.json" });
//Deletes data
db.delete("nonametxt.test");
db.remove("nonametxt.test");
Output:
{}
Add
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new Database({ dataPath: "./data.json" });
//Checks the data is available
db.exists("nonametxt.test");
db.has("nonametxt.test");
Output:
true or false
Typeof
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new Database({ dataPath: "./data.json" });
//If the data is a number, applies math operations to data.
db.math("nonametxt", "*", 10);
Output:
data * 10
Find
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new 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
import { Database } from "all.db";
const db = new 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.3.2 *
+ Fix push
Thx for use all.db.