3.2.0 • Published 11 months ago
odb.json v3.2.0
odb.json
Performance at its best! Uses JSON to store data.
npm i odb.json@latest
Database Examples
const Database = require('odb.json')
// Folder
const db = new Database.Database('./Local-Database-Folder', {
backup: {
enabled: true,
name: 'backup.json',
path: './Backup-Local-Database-Folder',
interval: 900000,
},
memory: {
enabled: true,
saveinterval: 30000,
},
cli: true, // When true type help in console for help
deep: true, // The dot notation that the world needs is here
file: 'Data.json' // The File to store Database
})
db.get("Data") // undefined
db.setNull("Data")
db.get("Data") // null
db.set("Data", "World");
// Get data
db.get("Data"); // World
// Delete data
db.delete("Data");
db.get("Data"); // undefined
db.has("Data"); // false
db.set("Just_a_number", 10); // 10
db.add("Just_a_number", 2); // 12
db.subtract("Just_a_number", 6); // 6
db.set("array", [ "apple" ]);
// db.push() creates an array if it doesn't exist
db.push("array", "orange"); // [ "apple", "orange" ]
// Remove element from array
db.remove("array", "apple"); // [ "orange" ]
db.type("array"); // Array
db.keys(); // ["Just_a_number", "array"]
db.values(); // 6, ["orange"]
db.clear(); // {}
db.save(); // Saves the database
db.size(); // Returns Database size
db.reload(); // Reloads the Database from disk
db.data(); // Returns the whole Database
Server-side Database setup
const Database = require('odb.json');
// Folder
const db-server = new Database.Server('./Database-folder-name', {
servertype: 'master' // Choose Master
port: 5555 // Port
})
Client-side Database
const Database = require('odb.json');
// IP Address
const db = new Database.Client('localhost', {
dbname: 'filename', // Database Name
username: "username", // Username
password: 'password', // Password
port: 5555 // Port
})
db.set("Data", "World");
// Get data
await db.get("Data"); // World
// Delete data
db.delete("Data");
await db.get("Data"); // undefined
await db.has("Data"); // false
db.set("Just_a_number", 10); // 10
db.add("Just_a_number", 2); // 12
db.subtract("Just_a_number", 6); // 6
db.set("array", [ "apple" ]);
// db.push() creates an array if it doesn't exist
db.push("array", "orange"); // [ "apple", "orange" ]
// Remove element from array
db.remove("array", "apple"); // [ "orange" ]
await db.type("array"); // Array
await db.keys(); // ["Just_a_number", "array"]
await db.values(); // 6, ["orange"]
db.clear(); // {}
Change Log
+ Added in-Memory Database to Database class (Memory enabled will save database when ever there is a change in data at the specified save interval)
+ Added New functions to Database class
+ keys()
+ values()
+ setNull()
+ Bug Fixes (Fixed my mistake while setting data as 0, false, null throws error), (Fixed the ability to type in console even while the cli is disabled), (Fixed saving to same file when using 2 instances of local database)
+ Ability to use a different separator for deep (currently ".")
+ Ability to make use of deep in the keys and values commands
Upcoming Features
+ Analytics of command usage
Support
If you have any doubts join my Discord => odb.json
Authors
3.2.0
11 months ago
3.0.2
12 months ago
3.1.0
11 months ago
3.0.1
12 months ago
3.0.0
12 months ago
2.1.9
2 years ago
2.1.4
2 years ago
2.1.6
2 years ago
2.1.8
2 years ago
2.1.7
2 years ago
2.1.2
2 years ago
2.1.1
2 years ago
2.1.3
2 years ago
2.1.0
2 years ago
2.0.1
2 years ago
2.0.0
2 years ago
1.1.4
2 years ago
1.1.3
2 years ago
1.1.2
2 years ago
1.0.2
2 years ago
1.0.1
2 years ago
1.0.0
2 years ago