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

feat(CustomPersistance): Added custom persistance #127

Closed
wants to merge 2 commits into from

Conversation

Drarig29
Copy link
Contributor

This is an indirect way of adding localStorage support (#22) and more...

It's fully backward compatible and enables the user to:

  • Disable the default file persistance behavior by passing null as a filename in the constructor
  • Give a custom saving method by passing a saveCallback in the constructor, which can be used with saveOnPush and save()

Although there won't be any file to load data from, you can still use resetData(data) to initialize data.
And you can use getData() or getData("/") to get the full data.

@coveralls
Copy link

coveralls commented Jul 23, 2020

Coverage Status

Coverage increased (+0.2%) to 95.053% when pulling 8e5dc8e on Drarig29:persistance into 95fc6ab on Belphemur:develop.

@Drarig29
Copy link
Contributor Author

Actually, I did this to be able to use node-json-db also in the browser, but:

  • It would be weird to use package named node-... inside a browser.
  • I thought using webpack would remove all imports about node's fs and that it would work seemlessly but it's not the case...

And without this, I don't know if this PR makes much sense anymore.

@Drarig29 Drarig29 closed this Jul 28, 2020
@kartonrad
Copy link

Yes this PR could have been useful for encrypting the json file!

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

Successfully merging this pull request may close these issues.

3 participants