SagsDbTs
Sags.db.ts is JSON database system.
Installation
npm install sags.db.ts
Usage
const sagsdb = require("sags.db.ts");
Default database name is "db".
Db name and folder name is must be String.
Database folder name is optional.
If u dont wanna minify set "minify" to false.
const db = new sagsdb({ name: "database", folder: "foldername", minify: true });
or
const db = new sagsdb({ name: "database", folder: "folder/database"});
or
const db = new sagsdb({ name: "database"});
You can create multi database.
const userdb = new sagsdb({ name: "userdb"});
const itemdb = new sagsdb({ name: "itemdb"});
COMMANDS
Set
Key must be a String or Number.
db.set("key", "apple");
Can't set Function.
function test(){
};
db.set("key", test);
Get
Key must be a String or Number.
db.set("key", "apple");
db.get("key");
Delete
Delete item from database.
db.set("key", "apple");
db.delete("key");
db.get("key");
Type
Check type for this key.
db.set("key", "apple");
db.type("key");
db.set("array", [1, 2, 3]);
db.type("array");
db.set("object", { a: 1, b: 2 });
db.type("object");
db.set("number", 1);
db.type("number");
Has
Check database for this key.
db.set("key", "apple");
db.has("key");
db.has("another");
Push
Push item in Array.
db.push("array", "apple");
db.get("array");
db.push("array","banana");
db.get("array");
Unpush
Unpush item from Array.
db.unpush("array", "apple");
db.get("array");
db.unpush("array", "apple");
db.get("array");
Add
Add number to number value.
Value must be a Number.
Default number is 1.
db.set("number", 1);
db.get("number");
db.add("number", 3);
db.get("number");
db.add("number");
db.get("number");
db.add("number", "asd");
Subtract
Subtract number to number value.
Value must be a Number.
Default number is 1.
db.set("number", 1);
db.get("number");
db.subtract("number", 3);
db.get("number");
db.subtract("number");
db.get("number");
db.subtract("number", "asd");
All
Return all Database object.
db.set("key", "apple");
db.set("number", 1);
db.all();
DeleteAll
Delete all database.
db.set("key", "apple");
db.get("key");
db.deleteAll();
db.get("key");
Dbsize
Get database size.
Number type is Byte (byte).
db.set("key", "apple");
db.dbSize();
U can set object in object.
db.set("key.value","apple");
db.get("key");
License
MIT