File tree 1 file changed +8
-3
lines changed
packages/components/nodes/memory/MongoDBMemory
1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -9,15 +9,20 @@ let mongoClientSingleton: MongoClient
9
9
let mongoUrl : string
10
10
11
11
const getMongoClient = async ( newMongoUrl : string ) => {
12
- if ( ! mongoClientSingleton || newMongoUrl !== mongoUrl ) {
12
+ if ( ! mongoClientSingleton ) {
13
+ // if client doesn't exists
14
+ mongoClientSingleton = new MongoClient ( newMongoUrl )
15
+ mongoUrl = newMongoUrl
16
+ return mongoClientSingleton
17
+ } else if ( mongoClientSingleton && newMongoUrl !== mongoUrl ) {
18
+ // if client exists but url changed
19
+ mongoClientSingleton . close ( )
13
20
mongoClientSingleton = new MongoClient ( newMongoUrl )
14
21
mongoUrl = newMongoUrl
15
- await mongoClientSingleton . connect ( )
16
22
return mongoClientSingleton
17
23
}
18
24
return mongoClientSingleton
19
25
}
20
-
21
26
class MongoDB_Memory implements INode {
22
27
label : string
23
28
name : string
You can’t perform that action at this time.
0 commit comments