jakearchibald / idb

IndexedDB, but with promises
https://www.npmjs.com/package/idb
ISC License
6.34k stars 357 forks source link

Support non-browser implementations of IndexedDB #259

Closed make-github-pseudonymous-again closed 2 years ago

make-github-pseudonymous-again commented 2 years ago

Is your feature request related to a problem? Please describe. I'd like to be able to use this wrapper with alternative implementations of IndexedDB. I know of three such implementations:

Describe the solution you'd like I know there is wrap that can be used once you get your hands on an instance produced by the IndexedDB API, but currently you cannot wrap the following two lines :

https://github.com/jakearchibald/idb/blob/82cad7cf582205f773da252a2cec188922c1f801/src/entry.ts#L52

https://github.com/jakearchibald/idb/blob/82cad7cf582205f773da252a2cec188922c1f801/src/entry.ts#L98

Would be nice to have either const {openDB} = wrap(indexedDB); or similar, or await openDB(name, version, {indexedDB, ...});.

Globally defining indexedDB with one of those implementations is also a solution but it is not a solution I like.

make-github-pseudonymous-again commented 2 years ago

I just tried to make idb work on top of indexeddbshim and I encountered issues similar to https://github.com/indexeddbshim/IndexedDBShim/issues/70 and https://github.com/indexeddbshim/IndexedDBShim/issues/361. Still trying to see if I can make something work.

jakearchibald commented 2 years ago

await openDB(name, version, {indexedDB, ...}) seems reasonable, but I guess there isn't a rush to do this while IndexedDBShim is buggy around its microtask timing.

make-github-pseudonymous-again commented 2 years ago

After further inspection it seems npm:indexeddbshim is incompatible with idb: the transaction automatic closing logic seems to be broken, I've tried both the browser implementation and the node implementation. Since npm:indexeddb is dated and since https://deno.land/x/indexeddb is based on npm:indexeddbshim I do not see any reason right now to implement support.

jakearchibald commented 2 years ago

Agreed. Hopefully a compatible implementation will appear in future. Happy to look at this again later.