{"id":27889639,"url":"https://github.com/hellivan/mongoose-model-migration","last_synced_at":"2025-05-05T10:25:14.056Z","repository":{"id":14705166,"uuid":"76900616","full_name":"hellivan/mongoose-model-migration","owner":"hellivan","description":"Library for up/downgrading and versioning mongoose models","archived":false,"fork":false,"pushed_at":"2023-01-07T04:37:46.000Z","size":1342,"stargazers_count":1,"open_issues_count":8,"forks_count":2,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-04-29T23:35:54.005Z","etag":null,"topics":["collection","migration","models","mongodb","mongoose","nodejs","typescript","versioning"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hellivan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-19T21:58:50.000Z","updated_at":"2021-10-28T07:49:07.000Z","dependencies_parsed_at":"2023-01-13T20:15:14.400Z","dependency_job_id":null,"html_url":"https://github.com/hellivan/mongoose-model-migration","commit_stats":null,"previous_names":[],"tags_count":19,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellivan%2Fmongoose-model-migration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellivan%2Fmongoose-model-migration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellivan%2Fmongoose-model-migration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hellivan%2Fmongoose-model-migration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hellivan","download_url":"https://codeload.github.com/hellivan/mongoose-model-migration/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252479084,"owners_count":21754484,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["collection","migration","models","mongodb","mongoose","nodejs","typescript","versioning"],"created_at":"2025-05-05T10:25:13.398Z","updated_at":"2025-05-05T10:25:14.042Z","avatar_url":"https://github.com/hellivan.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# mongoose-model-migration\n\n[![Build Status](https://img.shields.io/circleci/build/github/hellivan/mongoose-model-migration/master?logo=circleci\u0026style=flat-square)](https://circleci.com/gh/hellivan/mongoose-model-migration)\n[![Code Coverage](https://img.shields.io/codecov/c/github/hellivan/mongoose-model-migration/master?logo=codecov\u0026style=flat-square)](https://codecov.io/gh/hellivan/mongoose-model-migration)\n[![MIT License](https://img.shields.io/npm/l/mongoose-model-migration?style=flat-square)](LICENSE)\n[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=flat-square)](https://github.com/semantic-release/semantic-release)\n[![Renovate enabled](https://img.shields.io/badge/renovate-enabled-brightgreen.svg?style=flat-square)](https://renovatebot.com/)\n[![NPM Package](https://img.shields.io/npm/v/mongoose-model-migration?logo=npm\u0026style=flat-square)](https://www.npmjs.com/package/mongoose-model-migration)\n[![NPM Package Downloads](https://img.shields.io/npm/dm/mongoose-model-migration?logo=npm\u0026style=flat-square)](https://www.npmjs.com/package/mongoose-model-migration)\n\nUtility library that provides some basic mechanisms for versioning and upgrading mongoose models in Node.js\n\n## Installation\n\nUsing npm:\n\n```\nnpm install --save mongoose-model-migration\n```\n\nUsing yarn\n\n```\nyarn add mongoose-model-migration\n```\n\n## Usage\n\nIn ES6 / Typescript\n\n```typescript\nimport { migrateModel, migrateCollection } from 'mongoose-model-migration';\n```\n\n### Basic Collection migration\n\n```typescript\nimport { migrateCollection, CollectionMigrationHandler } from 'mongoose-model-migration';\n\nconst migrationHandler: CollectionMigrationHandler = {\n    up: async (db, collection, fromVersion, toVersion) =\u003e {\n        // ... call upgrate operations for collection\n    },\n    down: async (db, collection, fromVersion, toVersion) =\u003e {\n        // ... call downgrade operations for collection\n    }\n};\n\nawait migrateCollection('users', 2, migrationHandler);\n```\n\n### Collection migration options\n\n`migrateCollection` accepts an optional options object as 4th parameter:\n\n| option                | Description                                                                                                                        |\n| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- |\n| db                    | Optionally specify the mongodb database that should be used during migration. Defaults to the global mongoose `connection.db`      |\n| versionCollectionName | Optionally specify the collection name that should be used to store version information. Defaults to `collectionName + '.version'` |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellivan%2Fmongoose-model-migration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhellivan%2Fmongoose-model-migration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhellivan%2Fmongoose-model-migration/lists"}