hexojs / warehouse

JSON database

Home Page:https://hexojs.github.io/warehouse/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to save changes to the disk immediately after they happen?

tobice opened this issue · comments

Hey, I really like warehouse, it's been working great so far!

Is there a way (maybe hidden feature?) how to save the database to a file as soon as some changes occur? This might be very useful because now the database is just held in the memory and if the software crashes (before standard / scheduled save happens) the changes are lost.

I actually came up with a solution (methods for saving / loading from file are provided and all models are event emitters so I can easily listen for changes) but it doesn't seem very elegant. Mainly because I have to be careful about concurrent writes to the file to avoid file corruption.

Hey @tobice I'm just closing er' out due to how old it is. Sorry dood!