seald / nedb

The JavaScript Database, for Node.js, nw.js, electron and the browser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a way to close a DataStore?

g5becks opened this issue · comments

Hi, is there was a way to close a datastore? I looked around the api couldn't find an answer.

I have a situation where I am trying to conserve memory in my process and have - say 8 Datastores open at once, I would like to be able to close them and reopen them as needed at a later time.

Thanks.

commented

No there's no possibility to close a Datastore. However you can do the following:

  • call Datastore#stopAutocompaction to make sure no interval is set to compact the Datastore
  • call Datastore#compactDatafileAsync to make sure all changes are persisted to disk and compacted.
  • remove any reference to the Datastore and it should be automatically garbage collected.