w3c / IndexedDB

Indexed Database API
https://w3c.github.io/IndexedDB/
Other
240 stars 62 forks source link

IDL interface for the intersection of IDBObjectStore and IDBIndex? #367

Closed stefanhaustein closed 8 months ago

stefanhaustein commented 2 years ago

IDBObjectStore and IDBIndex APIs seem to be aligned in large parts, but this is not formalized as a shared interface in the spec.

We are using the spec to derive types (for jsdoc and j2cl), and an explicit IDL interface for the shared parts of IDBObjectStore and IDBIndex would help us abstract from the differences of IDBIndex and IDBObjectStore in code where the difference doesn't matter.

inexorabletash commented 2 years ago

We don't typically use interfaces this way on the web platform. Since the behavior is not actually identical between store and index, it wouldn't be functional inheritance (or each algorithm would have "if this is a store, do X; if it's an index, do Y", which defeats the purpose).

I understand the appeal when coming from a strongly typed language to have something like IIDBQueryable, but that's just not a pattern that's established for the web.