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 🙏

© 2026 – Pkg Stats / Ryan Hefner

discordjs-nextgen-db

v1.0.2

Published

Flexible, model-based database abstraction layer for discordjs-nextgen

Readme

discordjs-nextgen-db

Turkish Documentation (Türkçe Dökümantasyon)

A flexible, model-based database abstraction layer for discordjs-nextgen. Designed to be database-agnostic while providing a Mongoose-like developer experience.

🚀 Features

  • Adapter-Based: Support for Memory, SQLite, and more.
  • Model-Driven: Define models once, use them everywhere.
  • Auto-Loading: Automatically load model definitions from a directory (and subdirectories).
  • Framework Integration: Seamlessly integrates with discordjs-nextgen via app.db and ctx.db.
  • Type Safe: Full TypeScript support with module augmentation.

📦 Installation

npm install discordjs-nextgen-db

For SQLite support:

npm install better-sqlite3

🛠️ Setup

1. Register the Plugin

You can choose from several adapters. Use the folder option to automatically load models from a directory.

SQLite (Recommended for Small/Medium Bots)

npm install better-sqlite3
import { DatabasePlugin, SQLiteAdapter } from 'discordjs-nextgen-db';

app.use(new DatabasePlugin({
  folder: './models', // Auto-load models from this folder
  adapter: new SQLiteAdapter({ path: './database.sqlite' })
}));

MySQL (Recommended for Large/Scalable Bots)

npm install mysql2
import { DatabasePlugin, MySQLAdapter } from 'discordjs-nextgen-db';

app.use(new DatabasePlugin({
  folder: './models',
  adapter: new MySQLAdapter({
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'nextgen'
  })
}));

MongoDB / Mongoose (Recommended for NoSQL lovers)

npm install mongoose
import { DatabasePlugin, MongooseAdapter } from 'discordjs-nextgen-db';

app.use(new DatabasePlugin({
  folder: './models',
  adapter: new MongooseAdapter({
    uri: 'mongodb://localhost:27017/nextgen'
  })
}));

2. Define Your Models

Create a file in your models/ directory (e.g., models/user.ts):

export default (db) => {
  db.define('user');
};

💡 Usage

Access your models via ctx.db.<modelName> in commands or events.

CRUD Operations

// Create or Set
await ctx.db.user.create('123', { username: 'Burak', coins: 100 });

// Get
const user = await ctx.db.user.get('123');

// Update
await ctx.db.user.update('123', { coins: user.coins + 50 });

// Delete
await ctx.db.user.delete('123');

// Get All
const allUsers = await ctx.db.user.all();

📄 License

Apache-2.0