File tree Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Expand file tree Collapse file tree 2 files changed +4
-20
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ export interface MigrationModel {
7
7
}
8
8
9
9
export interface MigrationStore {
10
- init ( options : Record < string , unknown > ) : Promise < void > ;
10
+ init ( options : Record < string , unknown > ) : Promise < void > | void ;
11
11
getAppliedMigrations ( ) : Promise < MigrationModel [ ] > ;
12
12
insertMigration ( migration : Migration ) : Promise < void > ;
13
13
}
Original file line number Diff line number Diff line change 1
- import { Collection , MongoClient , MongoClientOptions } from 'mongodb' ;
1
+ import { Collection , Db } from 'mongodb' ;
2
2
3
3
import { Migration } from './Migration' ;
4
4
import { MigrationModel , MigrationStore } from './MigrationStore' ;
5
5
6
6
export class MongoMigrationStore implements MigrationStore {
7
7
private collection ?: Collection < MigrationModel > ;
8
8
9
- async init ( {
10
- uri,
11
- database,
12
- migrationsCollection,
13
- options,
14
- } : {
15
- uri : string ;
16
- database : string ;
17
- migrationsCollection : string ;
18
- options ?: MongoClientOptions ;
19
- } ) : Promise < void > {
20
- try {
21
- const client = await MongoClient . connect ( uri , options ) ;
22
- const db = client . db ( database ) ;
23
- this . collection = db . collection ( migrationsCollection ) ;
24
- } catch ( e ) {
25
- throw new Error ( e ) ;
26
- }
9
+ init ( { db, migrationsCollection } : { db : Db ; migrationsCollection : string } ) : void {
10
+ this . collection = db . collection ( migrationsCollection ) ;
27
11
}
28
12
29
13
getAppliedMigrations ( ) : Promise < MigrationModel [ ] > {
You can’t perform that action at this time.
0 commit comments