Closed cyrilletuzi closed 5 years ago
@robwormald @brandonroberts What's the status of ngrx/db? Why is it not maintained anymore?
@benlesh Are you aware of any existing and maintained implementation of indexedDb
in RxJS?
Thanks for your feedback guys.
This library seems to be well maintained and highly compatible: https://github.com/pubkey/rxdb/blob/master/README.md
@fmavdb Seen this one. Seems very good but I think it goes too far for the purpose here.
Started the work about this and realized the requested operations are currently not possible because the lib is just missing a few low-level methods. Adding them would allow everything, without the lib having to provide an advanced query API.
As the idea of the lib is to imitate the native localStorage
API, the missing things would be:
.key(index)
method.length
propertyI've done the implementation, and it works, but clearly it's not a good solution because:
indexedDb
is not conceived to work that way (for example, iterating over all items would need to iterate with .key()
and .size
, which would work but do n
indexedDb
requests (where n
is the number of items), while it could be done in a single indexedDb
operation).A better solution would be to imitate the Map
API, with methods like keys()
.
Problem is now how to handle this, so the API stays consistent. I see several scenarios possible:
Just add missing keys()
and other Map
-like methods in the current service
localStorage
and others from Map
Add missing keys()
but also methods for already existing operations like get()
, set()
and keep the old ones (getItem
, setItem
...)
Add missing keys()
but also methods for already existing operations like get()
, set()
and deprecate the old ones (getItem
, setItem
...)
Keep the existing LocalStorage
service as is, and add a new LocalStorageMap
one with Map
-like methods
@fmavdb @juristr @dphochman @rajd90 What do you think?
.keys()
method and .size
property have been added in 7.1.0-beta.0. To test:
npm install @ngx-pwa/local-storage@beta
Feedback welcome.
For info, there is currently a compatibility issue for has()
and keys()
in IE/Edge, see #69
This issue tracks the project of a full query API.
Design
The API with all methods needs to be designed. It would be better to be inspired by an existing implementation (dexis.js seems to be the reference for
indexedDb
).Already requested:
Please comment with all methods that would be useful in your projects.
Warning: each method should also work when in
localStorage
fallback scenarios, and performance should be checked in this case.Implementation
As we're going towards a full RxJS adaptation of
indexedDb
, it would be better to be done in a framework agnostic new lib, which would be used by this one.Maybe it already exists?