AikoDB is a lightweight, fast, and easy-to-use database module based on JSON. It's perfect for use in small projects, prototyping, or even Discord bots where a full-scale database system is overkill.
Install via npm:
npm install aikodb
Using AikoDB is extremely simple. You can start using it with just a few lines:
const AikoDB = require('aikodb');
const db = new AikoDB('json', 'database.json');
(async () => {
await db.set('user1', { xp: 50 });
console.log(db.get('user1'));
await db.push('logs', 'Login Users.');
console.log(db.get('logs'));
console.log(db.has('user1')); // true
console.log(db.size()); // database entry count
await db.removeFromArray('logs', 'Login Users.');
console.log(db.get('logs'));
await db.clear(); // clears all data
})();
Adds a key with the given value to the database. Alias of set()
.
Returns the value of the given key.
Creates or updates a key with the specified value.
Deletes the specified key from the database.
Returns the entire database object.
Pushes a value to an array stored under the key. Creates the array if it doesn't exist.
Clears the entire database.
Returns true if the key exists in the database.
Returns the number of entries in the database.
Returns an array of all keys.
Returns an array of all values.
Filters entries based on a function.
db.filter(item => item.age > 20);
Returns entries where object[property] === value
.
db.find("username", "furkan");
Sorts data by key and order (asc
or desc
).
db.sort("xp", "desc");
Reloads the data from the file.
Manually saves the current state to the file.
const AikoDB = require('aikodb');
const db = new AikoDB('json', 'data.json');
client.on('messageCreate', async message => {
if (message.author.bot) return;
const userId = message.author.id;
const user = db.get(userId) || { xp: 0 };
user.xp += 10;
await db.set(userId, user);
});
Need help? Join our Discord server
Get help on the #support channel.
Or DM me directly via my Discord profile.