Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asyncOnWrite operations should return a Promise #8

Open
mnbroatch opened this issue May 25, 2021 · 5 comments
Open

asyncOnWrite operations should return a Promise #8

mnbroatch opened this issue May 25, 2021 · 5 comments

Comments

@mnbroatch
Copy link

mnbroatch commented May 25, 2021

As it is, there doesn't seem to be a hook that lets the program know that writing is done, and as a result my database is randomly corrupted on program exit (in the middle of a write operation). Promise wrapper seems the most obvious way to handle this, but we need SOMETHING.

@nmaggioni
Copy link
Owner

If your concurrency model requires stronger guarantees I'd suggest you to move to a proper storage method instead of hardening this old toy JSON wrapper. Anyway, PRs are always welcome.

@iyobo
Copy link

iyobo commented Nov 27, 2021

It's not hard to roll your own json file disk storage honestly.
For starters, if you want to keep your data safe, all saving should happen to a different temp file and then, after success, replace main json file with temp file.

This is how apps with file-based DBs like MSWord, etc do it to prevent corruption.
I do not know if this lib works that way.

My point is, don't depend so much on toy libraries like these with limited safeties and overly simplistic implementations. These things are easy to implement by yourself using core node.

@a-a-GiTHuB-a-a
Copy link
Contributor

No, it doesn't...but honestly, I think adding Promises would be nice.

@a-a-GiTHuB-a-a
Copy link
Contributor

Maybe you could submit a PR.

@a-a-GiTHuB-a-a
Copy link
Contributor

I added a PR including this enhancement: #18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants