node-json-db icon indicating copy to clipboard operation
node-json-db copied to clipboard

Add localestorage support

Open Belphemur opened this issue 8 years ago • 5 comments

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

Belphemur avatar Aug 28 '16 16:08 Belphemur

Currently not possible without a rework (requires('') compatibility required for current implementation).

I'm working on it though, as one with Promises.

Not published, but see https://github.com/ZaneHannanAU/db-dot-json for more information.

ZaneHannanAU avatar May 12 '17 22:05 ZaneHannanAU

@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 avatar May 15 '17 15:05 Belphemur

@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 avatar May 16 '17 02:05 ZaneHannanAU

@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 avatar May 16 '17 12:05 Belphemur

@Belphemur I think an easier solution would be to:

  • Make the file persistance optional (for example by allowing null as a database filename in the JsonDB 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 😁

Drarig29 avatar Jul 22 '20 17:07 Drarig29