qdatabase v3.8.1
QDB3
JSON Data Mangement
From this release onwards, we will backport features from v4 and start to migrate to SQL (with JSON support).
QDB is a high level data management for storing local JavaScript Objects without corruptions. Connect to multiple JSON files, use connection pooling, edit data directly or use QDB's built-in functions.
Main Features
- Store in JSON. Easily managable or use QDB's utility functions.
- Create pools and manage multiple JSON databases.
- Introducing Collection classes from Discord.js. (Full rights to them.)
- Extended to Cache collections and DataStores.
- Added DataManagers, Queues and Stacks.
Links
Main Import
npm install qdatabase
const QDB = require("qdatabase");
const MyDB = new QDB.Connection("./Data/Databases.json");
// ...
Database Usage
The below example allows for debug logging, connects to a database ./Databases/Users.json
and sets an object in the database.
// A debug logger for QDB.
process.on("QDB-Debug", n => console.log(n));
const QDB = require("qdatabase");
const MyDB = new QDB.Connection("./Databases/Users.json", {
Polling: true // Multi-process access.
});
// Set an object into the 'Users' database.
// Check out utility methods to interact with data in the documentations.
MyDB.Set({User: "Smally", Job: "Software Engineer"});
The following example connects to a folder ./Databases/
of database files automatically using a pool.
const QDB = require("qdatabase");
const DBS = new QDB.Pool("./Databases/");
// Fetch the 'User' from the database table.
DBS.Select("Users").Fetch("User");
// -> "Smally"
// Append "Full-Stack Developer" to the 'Jobs' database,
// assuming the origin is an array of jobs.
DBS.Select("Jobs").Append("Full-Stack Developer");
Utility Usage
Check out the base utility repository here.
Cache
Extends Collection
A Collection with extended custom caching features.
const Cache = new QDB.Cache();
// An ID tracker by the Cache.
// Automatically increments after use.
Cache.set(Cache.id, 872639);
// Utility functions.
Cache.increment(0); // Increment key '0'.
Cache.decrement(1); // Decrement key '1'.
Cache.add(2, 5); // Add 5 to key '2'.
Cache.subtract(3, 5); // Subtract 5 from key '3'.
Cache.multiply(4, 3); // Multiply key '4' with 3.
Cache.divide(5, 3); // Divide key '5' with 3.
// Additional math operations.
Cache.square(6); // Square key '6'.
Cache.power(7, 4); // Key '7' to the power of 4.
Cache.root(8); // Key '8' to the power of 2.
Cache.exp(9); // Euler's number ^ key '8'
Cache.absolute(10); // Make key '10' absolute.
// Accumulates a function on the cache key.
Cache.accumulate(4, (Val, Key, Self) => {
return (Val + 10) * 3; // Adds 10 to key '4', multiplies it by 3.
});
Stack
A manager for temporarily storing mass data in sequence.
// Push a datastream onto a Stack for later access.
const Stack = new QDB.Stack(DataStream);
// Seek in the Stack.
Stack.Seek(3);
Bug/Issues/Features
If you have found a bug, want to suggest a feature or need help with QDB, please contact me at Discord with the tag QSmally#3594
. On the other hand, if you would like to join the server, the invite link can be found at our site. You can also subject an issue on the Github repo.
Contributing
This module is licensed under MIT. Feel free to contribute by forking the repository, or cloning the master branch for in-progress features.
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago