npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

aikodb

v1.1.3

Published

AikoDB, JSON and YAML database module for simple and easy use, ideal for Discord bots.

Downloads

37

Readme

Downloads DownloadPerMonth

AikoDB

AikoDB is a simple and easy-to-use database module that supports both JSON-based databases. It is especially ideal for Discord bots.

Installation

You can install AikoDB using npm:

npm install aikodb

Usage Using AikoDB is very simple. You can create a JSON database and perform various database operations.

Usage with Discord Bot Using AikoDB with a Discord bot is also very straightforward. Here is a simple example:


const { Client, GatewayIntentBits, Partials } = require('discord.js');
const client = new Client({
  intents: Object.values(GatewayIntentBits),
  partials: Object.values(Partials),
  shards: 'auto'
});
const AikoDB = require('aikodb'); // Added AikoDB module

// Create a database with AikoDB
const db = new AikoDB('json', 'data.json'); // const yamlDb = new AikoDB('yaml','aikodb yml');

client.on('ready', () => {
  console.log(`Logged in as ${client.user.tag}!`);
});

client.on('messageCreate', async message => {
  if (message.content.startsWith('!set')) {
    const args = message.content.slice('!set'.length).trim().split(' ');
    const key = args[0];
    const value = args.slice(1).join(' ');

    await db.set(key, value);
    message.channel.send(`Data set successfully: ${key} -> ${value}`);
  } else if (message.content.startsWith('!get')) {
    const key = message.content.slice('!get'.length).trim();

    const value = db.get(key);
    if (value) {
      message.channel.send(`Data found: ${key} -> ${value}`);
    } else {
      message.channel.send(`Data not found: ${key}`);
    }
  }
});

client.login('YOUR_BOT_TOKEN');

API

add(key, value)
Adds the specified key and value to the database.

get(key)
Retrieves the value for the specified key.

set(key, value)
Updates or adds the value for the specified key.

delete(key)
Deletes the data for the specified key.

all()
Returns the entire contents of the database.

deleteAll()
Deletes all the contents of the database.

push(key, value)
Adds a value to the array for the specified key. If the key does not exist, it creates a new array.

filter(callback)
Filters saved data within data based on the callback function.

search(key, value)
Searches for data entries that match the specified key-value pair.

sort(key, order = 'asc')
Sorts the database entries based on the specified key and order (ascending or descending).

Example for Advanced Features Here's how to use the new filter, search, and sort features:

const AikoDB = require('aikodb'); // Added AikoDB module

// Create a database with AikoDB
const db = new AikoDB('json', 'data.json');

async function advancedFeatures() {
  await db.set('user1', { name: 'Furki', age: 25 });
  await db.set('user2', { name: 'Ufuk', age: 30 });
  await db.set('user3', { name: 'Nazmi', age: 20 });

  // Filter users by age > 20
  const filteredUsers = db.filter(user => user.age > 20);
  console.log('Filtered Users:', filteredUsers);

  // Search user by name
  const searchedUser = db.search('name', 'Alice');
  console.log('Searched User:', searchedUser);

  // Sort users by age
  const sortedUsers = db.sort('age', 'asc');
  console.log('Sorted Users:', sortedUsers);
}

advancedFeatures();

✨ Support

You can come to our Discord server and get help and support on #support channel. Or if you send a friend to my discord account, I will return as soon as possible.