Skip to content

Commit 1c108f3

Browse files
committed
update
1 parent 51388d5 commit 1c108f3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

packages/components/nodes/memory/MongoDBMemory/MongoDBMemory.ts

+8-3
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,20 @@ let mongoClientSingleton: MongoClient
99
let mongoUrl: string
1010

1111
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()
1320
mongoClientSingleton = new MongoClient(newMongoUrl)
1421
mongoUrl = newMongoUrl
15-
await mongoClientSingleton.connect()
1622
return mongoClientSingleton
1723
}
1824
return mongoClientSingleton
1925
}
20-
2126
class MongoDB_Memory implements INode {
2227
label: string
2328
name: string

0 commit comments

Comments
 (0)