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

@seedcord/plugin-mongoose

v0.4.2

Published

Connect a seedcord bot to MongoDB with Mongoose

Readme

npm node license

About

@seedcord/plugin-mongoose connects a seedcord bot to MongoDB through Mongoose. It opens the connection during startup, loads every class under dir that carries @RegisterMongooseService, builds each one's model from its schema, and exposes them under the key you attached it on.

It runs on the gateway transport and on http's server runtime. Attaching it to an edge host is a compile error, since Mongoose opens a TCP connection that edge runtimes have no socket for.

Until v1.0.0, minor versions can break.

Installation

pnpm add @seedcord/plugin-mongoose mongoose

mongoose, envapt, typescript, and @seedcord/core are peer dependencies.

Attach

attach takes a property name, the plugin class, and its options. Chain it off the constructor:

// bot.ts
import { resolve } from 'node:path';

import { Seedcord } from '@seedcord/gateway';
import { Mongoose } from '@seedcord/plugin-mongoose';

export const seedcord = new Seedcord(config).attach('db', Mongoose, {
    dir: resolve(import.meta.dirname, './services'),
    uri: Vars.mongoUri,
    name: Vars.dbName
});

export default seedcord;
// index.ts
import seedcord from './bot';

await seedcord.start();

attach returns the instance widened with the key, and seedcord codegen writes db: (typeof Bot)['db'] into seedcord-gen.d.ts off a default import of that module. Calling attach as a bare statement drops the widened type. A named-only export leaves codegen with nothing to import.

Attach before startup. A call after initialization throws CorePluginAfterInit.

Vars stands in for an envapt class. A process.env read types as string | undefined, which the required uri and name reject.

Services

Declare the schema on the class as a public static schema. A class without one is a compile error.

import { MongooseService, RegisterMongooseService } from '@seedcord/plugin-mongoose';
import mongoose from 'mongoose';

interface IUser {
    userId: string;
    balance: number;
}

@RegisterMongooseService('users')
export class Users extends MongooseService<IUser> {
    public static schema = new mongoose.Schema<IUser>({
        userId: { type: String, required: true, unique: true },
        balance: { type: Number, default: 0 }
    });

    public async findByUserId(userId: string) {
        return this.model.findOne({ userId });
    }
}

Name each key once so the lookup types resolve:

declare module '@seedcord/plugin-mongoose' {
    interface MongooseServices {
        users: Users;
    }
}

Then call it from a handler through core:

const user = await this.core.db.services.users.findByUserId(this.event.user.id);