[release] v0.15.0-unstable19

This commit is contained in:
Yann Stepienik
2024-03-25 11:57:50 +00:00
parent 59911584b3
commit 0d31f5dbff
2 changed files with 15 additions and 2 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "cosmos-server",
"version": "0.15.0-unstable18",
"version": "0.15.0-unstable19",
"description": "",
"main": "test-server.js",
"bugs": {
+14 -1
View File
@@ -125,6 +125,9 @@ func DisconnectDB() {
client = nil
}
var embeddedClient lungo.IClient
var embeddedClientClose func()
func GetEmbeddedCollection(applicationId string, collection string) (lungo.ICollection, func(), error) {
opts := lungo.Options{
Store: lungo.NewFileStore(CONFIGFOLDER + "database", 700),
@@ -134,6 +137,13 @@ func GetEmbeddedCollection(applicationId string, collection string) (lungo.IColl
name = "COSMOS"
}
if embeddedClient != nil {
c := embeddedClient.Database(name).Collection(applicationId + "_" + collection)
return c, func() {
//engine.Close()
}, nil
}
// open database
client, engine, err := lungo.Open(nil, opts)
if err != nil {
@@ -145,8 +155,11 @@ func GetEmbeddedCollection(applicationId string, collection string) (lungo.IColl
c := client.Database(name).Collection(applicationId + "_" + collection)
embeddedClient = client
embeddedClientClose = engine.Close
return c, func() {
engine.Close()
//engine.Close()
}, nil
}