node-json-db
node-json-db copied to clipboard
Add localestorage support
To be able to use it in browser easily and rely on the storage mechanism there.
- [ ] Create a storage "interface"
- [ ] Implement driver for hard storage (current one)
- [ ] Implement storage for LocalStorage
Currently not possible without a rework (requires('')
compatibility required for current implementation).
I'm working on it though, as one with Promise
s.
Not published, but see https://github.com/ZaneHannanAU/db-dot-json for more information.
@ZaneHannanAU Great work on implementing the Promises :)
I admit I gave up on Async as it was overkill for the usage I had of the lib at the time (hence the decision to use Sync filesystem calls).
@Belphemur The biggest issue with mine right now is that it doesn't work at all.
As in, not even the tests work lol
Anyway, once you go promise for one thing; everything else must become a promise.
@ZaneHannanAU Yep, Promises are a double edge sword. One that I didn't wanted to impose on the user.
Also at the time I started the lib, there were easily 5-6 differents promise lib...
@Belphemur I think an easier solution would be to:
- Make the file persistance optional (for example by allowing
null
as a database filename in theJsonDB
constructor) - Add a public method exposing the private field named
data
(maybe a copy for security concerns) - Let the user make his own solution (either outside of the library, or by passing a save callback function) to persist data manually
- Persisting in json files would remain the default behavior
I can do it in a PR... I need this feature 😁