denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.73k stars 5.26k forks source link

deno-idb not browser idb #14160

Closed elycheikhsmail closed 2 years ago

elycheikhsmail commented 2 years ago

The IDB API implemented in browser is not intuitive and very verbose. I hope see nosql asynchron db for browser and deno with inuitive and less verbose api. How can this implemented ? we can dissuss about this later.

kitsonk commented 2 years ago

IndexedDB is a web platform standard, even if the API is not very good.

Deno implementing something that is non-standard only goes to fracture the eco-system further, which is not a goal we have as part of the Deno core team.

There are quite a few "sane" APIs that are built upon IndexedDB that provide a much better API surface, for example PouchDB. By implementing the web standard, it means that we should be able to allow a lot of users to use already built solutions, like PouchDB.

If you want to see a better web platform DB API, it is best to pursue that with the WHATWG. There was an attempt by Google to bring a KV Store API built upon IndexedDB built into the web platform, but they have abandoned it.

crowlKats commented 2 years ago

The most actionable thing that we can do is have a wrapper API in std, similar to the existing ones, but that then raises a question: why not use those then? why would it have to be part of std?

elycheikhsmail commented 2 years ago

IndexedDB is a web platform standard, even if the API is not very good.

Deno implementing something that is non-standard only goes to fracture the eco-system further, which is not a goal we have as part of the Deno core team.

There are quite a few "sane" APIs that are built upon IndexedDB that provide a much better API surface, for example PouchDB. By implementing the web standard, it means that we should be able to allow a lot of users to use already built solutions, like PouchDB.

If you want to see a better web platform DB API, it is best to pursue that with the WHATWG. There was an attempt by Google to bring a KV Store API built upon IndexedDB built into the web platform, but they have abandoned it.

the idea is to implement something like pouchDB directly in deno and or deno std (without be linked to indexedDB) on top of top this we build indexedDB api. the web standard and spec continue to be respected ( indexedDB in our context) but with alternative can be used in real app

kitsonk commented 2 years ago

Why force that choice on the users?

A design principle for Deno has been only to implement non-standard APIs when there is not a way to do it with existing standards, and try to keep the APIs low-level. Every time we implement a non-standard API, we enable users to create code that only works on Deno and we further fracture the eco-system. Not something we take lightly.

PouchDB is not the only higher-order sane API for local persistence built on top of IndexedDB.

The std library exists for things that are "generally good ideas that are commonly used but optional". Once IndexedDB is available in Deno, it might make sense to add something, but if there are sufficient solutions already available, I doubt it would make sense.

That is a main reason KV Store was abandoned. It was just an overlay onto IndexedDB, easily provided by a user if they so choose. Forcing it as another API in every browser using the same low level "ugly" APIs was considered unnecessary.

I think we have explained our reasoning and logic here.

A KV Store like API might make sense in std to lower the friction of persisting data locally, but that would be an issue to discuss once IndexedDB is available, and for the std repo. Therefore I am closing this issue.