diff --git a/types/umzug/index.d.ts b/types/umzug/index.d.ts index f74c5933be..a163ea01d9 100644 --- a/types/umzug/index.d.ts +++ b/types/umzug/index.d.ts @@ -1,13 +1,15 @@ -// Type definitions for Umzug v2.1.0 +// Type definitions for Umzug v2.2.0 // Project: https://github.com/sequelize/umzug // Definitions by: Ivan Drinchev // Margus Lamp // Troy McKinnon +// Emmanuel Gautier // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.8 import { EventEmitter } from 'events'; import Sequelize = require("sequelize"); +import MongoDB = require("mongodb"); declare namespace umzug { @@ -116,6 +118,27 @@ declare namespace umzug { } + interface MongoDBStorageOptions extends Storage { + + /** + * The MongoDB database connection instance. + */ + connection?: MongoDB.Db; + + /** + * The to be used Mongo collection cursor. + * Defaults to collection created from collectionName attribute. + */ + collection?: MongoDB.Collection; + + /** + * The name of the collection used by the connection. + * Defaults to 'migrations' + */ + collectionName?: string; + + } + interface ExecuteOptions { migrations?: Array; method?: string; @@ -125,12 +148,12 @@ declare namespace umzug { /** * The storage. */ - storage?: "json" | "sequelize" | Storage; + storage?: "json" | "sequelize" | "mongodb" | Storage; /** * The options for the storage. */ - storageOptions?: JSONStorageOptions | SequelizeStorageOptions | Object; + storageOptions?: JSONStorageOptions | SequelizeStorageOptions | MongoDBStorageOptions | Object; /** * The logging function. diff --git a/types/umzug/umzug-tests.ts b/types/umzug/umzug-tests.ts index 95ccf15665..730f350315 100644 --- a/types/umzug/umzug-tests.ts +++ b/types/umzug/umzug-tests.ts @@ -1,5 +1,6 @@ import Umzug = require('umzug'); import Sequelize = require('sequelize'); +import MongoDB = require('mongodb'); let someVar: Umzug.Umzug; const umzug = new Umzug({}); @@ -44,7 +45,7 @@ umzug.on('reverted', (name: string, migration: Umzug.Migration) => null); new Umzug({ // The storage. - // Possible values: 'json', 'sequelize', an object + // Possible values: 'json', 'sequelize', 'mongodb' an object storage: 'json', // The options for the storage. @@ -80,7 +81,7 @@ new Umzug({ new Umzug({ // The storage. - // Possible values: 'json', 'sequelize', an object + // Possible values: 'json', 'sequelize', 'mongodb' an object storage: 'json', storageOptions: { path: '/db/sequelize-meta.json', @@ -121,3 +122,30 @@ new Umzug({ }, }); + +const mongodb = new MongoDB.Db('database', new MongoDB.Server('host', 21017)); + +new Umzug({ + // The storage. + // Possible values: 'json', 'sequelize', 'mongodb' an object + storage: 'mongodb', + storageOptions: { + /** + * The MongoDB database connection instance. + */ + connection: mongodb, + + /** + * The to be used Mongo collection cursor. + * Defaults to collection created from collectionName attribute. + */ + collection: mongodb.collection, + + /** + * The name of the collection used by the connection. + * Defaults to 'migrations' + */ + collectionName: 'migrations' + }, + +});