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

@coodex.ai/mongo-migrations

v0.1.6

Published

Tool to manage migrations in MongoDB

Readme

Mongo Migrations

Tool to manage migrations in MongoDB.

Installation

npm install @coodex.ai/mongo-migrations

Creating Migrations

Create a new migration file using the CLI command:

npx mongo-migrations create <migration-name>

Or if installed globally:

npm install -g @coodex.ai/mongo-migrations
mongo-migrations create add-user-indexes

This will create a new migration file in the src/migrations directory (or the path specified by MIGRATIONS_PATH environment variable) with the following structure:

import { Db } from 'mongodb';

export async function up(db: Db): Promise<void> {
  // Implement your migration here
  // Example:
  // await db.collection('users').createIndex({ email: 1 }, { unique: true });
}

export async function down(db: Db): Promise<void> {
  // Implement rollback here
  // Example:
  // await db.collection('users').dropIndex('email_1');
}

Usage

const { MigrationManager } = require('@coodex.ai/mongo-migrations');

// Option 1: Using environment variables (MONGO_URI and DB_NAME)
const manager = new MigrationManager({
  migrationsPath: './src/migrations'
});

// Option 2: Explicit configuration
const manager = new MigrationManager({
  uri: 'mongodb://localhost:27017',
  database: 'my-database',
  migrationsPath: './src/migrations'
});

// Option 3: Mix of both (explicit config takes precedence)
const manager = new MigrationManager({
  database: 'my-database', // explicit
  // uri will use MONGO_URI from env
  migrationsPath: './src/migrations'
});

// Run pending migrations
await manager.up();

CLI Command

You can also run migrations using the CLI command. The CLI automatically loads variables from .env file:

# Option 1: Using .env file (recommended)
# Create a .env file in your project root:
# MONGO_URI=mongodb://localhost:27017
# DB_NAME=my-database
# MIGRATIONS_PATH=./src/migrations  # Optional

npx mongo-migrations up

# Option 2: Using environment variables
export MONGO_URI="mongodb://localhost:27017"
export DB_NAME="my-database"
export MIGRATIONS_PATH="./src/migrations"  # Optional, defaults to ./src/migrations
npx mongo-migrations up

Or if installed globally:

npm install -g @coodex.ai/mongo-migrations
mongo-migrations up

Environment Variables

  • MONGO_URI - MongoDB connection string (required for CLI)
  • DB_NAME - Database name (required for CLI)
  • MIGRATIONS_PATH - Path to migrations directory (defaults to ./src/migrations)

Development

# Install dependencies
npm install

# Compile TypeScript
npm run build

# Run tests
npm test

# Watch mode for development
npm run watch

Publishing

# Build before publishing
npm run build

# Publish to npm
npm publish

License

GPL-3.0