mirror of
https://github.com/azukaar/Cosmos-Server.git
synced 2026-05-02 17:19:51 -05:00
[release] v0.15.0-unstable19
This commit is contained in:
+1
-1
@@ -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
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user