@@ -4,7 +4,7 @@ import { MongoClient, ObjectID } from "mongodb";
44export class MongoDBPersistence implements IPersistenceProvider {
55
66 public connect : Promise < void > ;
7- private db : any ;
7+ private client : any ;
88 private workflowCollection : any ;
99 private subscriptionCollection : any ;
1010 private eventCollection : any ;
@@ -13,14 +13,16 @@ export class MongoDBPersistence implements IPersistenceProvider {
1313
1414 constructor ( connectionString : string ) {
1515 var self = this ;
16- this . connect = new Promise < void > ( ( resolve , reject ) => {
17- MongoClient . connect ( connectionString , ( err , db ) => {
16+ this . connect = new Promise < void > ( ( resolve , reject ) => {
17+ const options = { useNewUrlParser : true , useUnifiedTopology : true } ;
18+ MongoClient . connect ( connectionString , options , ( err , client ) => {
1819 if ( err )
1920 reject ( err ) ;
20- self . db = db ;
21- self . workflowCollection = self . db . collection ( "workflows" ) ;
22- self . subscriptionCollection = self . db . collection ( "subscriptions" ) ;
23- self . eventCollection = self . db . collection ( "events" ) ;
21+ self . client = client ;
22+ const db = self . client . db ( ) ;
23+ self . workflowCollection = db . collection ( "workflows" ) ;
24+ self . subscriptionCollection = db . collection ( "subscriptions" ) ;
25+ self . eventCollection = db . collection ( "events" ) ;
2426 resolve ( ) ;
2527 } ) ;
2628 } ) ;
0 commit comments