update
This commit is contained in:
parent
36ab1681ac
commit
51388d5057
|
|
@ -5,12 +5,15 @@ import { mapStoredMessageToChatMessage, AIMessage, HumanMessage, BaseMessage } f
|
||||||
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
import { convertBaseMessagetoIMessage, getBaseClasses, getCredentialData, getCredentialParam } from '../../../src/utils'
|
||||||
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
import { FlowiseMemory, ICommonObject, IMessage, INode, INodeData, INodeParams, MemoryMethods, MessageType } from '../../../src/Interface'
|
||||||
|
|
||||||
let mongoClientSingleton = null
|
let mongoClientSingleton: MongoClient
|
||||||
|
let mongoUrl: string
|
||||||
|
|
||||||
const getMongoClient = async (mongoDBConnectUrl) => {
|
const getMongoClient = async (newMongoUrl: string) => {
|
||||||
if (!mongoClientSingleton) {
|
if (!mongoClientSingleton || newMongoUrl !== mongoUrl) {
|
||||||
mongoClientSingleton = new MongoClient(mongoDBConnectUrl, { useNewUrlParser: true, useUnifiedTopology: true })
|
mongoClientSingleton = new MongoClient(newMongoUrl)
|
||||||
|
mongoUrl = newMongoUrl
|
||||||
await mongoClientSingleton.connect()
|
await mongoClientSingleton.connect()
|
||||||
|
return mongoClientSingleton
|
||||||
}
|
}
|
||||||
return mongoClientSingleton
|
return mongoClientSingleton
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue