Registry / database / migroose

migroose

JSON →
library0.5.1jsnpmunverified

Migroose (v0.5.1) is a migration framework for MongoDB and MongooseJS, designed to handle structural changes to collections and documents. It provides an API for loading data from old collections, running custom migration steps, and dropping or removing data. Migrations are idempotent using timestamps and are meant to be run with the migroose-cli tool. Compared to other migration tools like migrate-mongoose, migroose focuses on raw MongoDB collection access rather than Mongoose models for data manipulation. The package appears to be in early development (v0.x) and has not seen recent updates (last release over 5 years ago), indicating maintenance mode or potential abandonment.

npm install migroose
INSTALL
IMPORT
SIG · MIGROOSE
M
migroose
databasejavascriptv0.5.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Migration
const { Migration } = require('migroose');
import { Migration } from 'migroose';
Migroose is CommonJS-only; ES imports are not supported. Use require().
migroose
const migroose = require('migroose');
import migroose from 'migroose';
Default export is an object with Migration and helpers. CommonJS required.
Types
// No TypeScript types available; use @types/migroose or manual definition
import { Migration } from 'migroose';
Migroose does not ship TypeScript declarations. Use @ts-ignore or create your own.

Demonstrates creating a migration that loads data from an old collection, transforms and inserts it into a new collection, then removes and drops the old collection.

// Step 1: Install dependencies // npm install migroose mongoose // Step 2: Create a migration file (using migroose-cli or manually) // migrations/1234567890-example-migration.js const { Migration } = require('migroose'); module.exports = new Migration(1234567890, (migration) => { migration.load({ oldData: 'old_collection' }); migration.step((data, stepComplete) => { const documents = data.oldData.documents; const collection = data.oldData.collection; // Transform documents const newDocs = documents.map(doc => ({ ...doc, newField: 'default' })); collection.insertMany(newDocs, stepComplete); }); migration.remove({ oldData: 'old_collection' }); migration.drop([ 'old_collection' ]); });
Debug
Known issues
gotchaMigroose uses raw MongoDB collection access, not Mongoose models. Methods like .save() will not work; use native MongoDB driver methods.
fix
Use collection.insertMany(), collection.updateOne(), etc. directly from data object.
affects: >=0.1.0
gotchaSteps are queued and executed in order, but if you drop a collection before loading data from it, load will fail. Ensure load steps come before drops.
fix
Always call .load() before .drop() or .remove() for the same collection.
affects: >=0.1.0
gotchaMigration IDs must be unique. Using a timestamp (e.g., Date.now()) is common, but collisions are possible if multiple migrations are created in the same millisecond.
fix
Use sequential integers or longer timestamps (e.g., YYYYMMDDHHmmss) instead of milliseconds.
affects: >=0.1.0
deprecatedThe package has not been updated since 2018 and may have compatibility issues with newer versions of Mongoose (v5+).
fix
Consider using 'migrate-mongoose' or 'mongodb-migrations' instead.
affects: >=5.0.0
Errors
Common errors & fixes
Cannot find module 'migroose'
Missing npm install or wrong require path.
fix
Run 'npm install migroose' and use require('migroose') (not require('migroose-cli')).
TypeError: migration.load is not a function
Using default export instead of destructuring Migration class.
fix
Use 'const { Migration } = require('migroose');' instead of 'const migroose = require('migroose'); new migroose.Migration(...)'.
Migration ID must be a number
Passing a string or non-numeric value as the first argument to Migration constructor.
fix
Use a numeric value, e.g., new Migration(1234567890, ...).
Upgrade
Version history
0.5.1latest on npm
Audit
Dependencies
mongooserequiredMigroose is designed to work with Mongoose models and requires Mongoose to be installed in the project.
Agent activity
9 hits · last 30 days
node
8
Resources
migroose — npm install migroose · libregistry