-
-
Notifications
You must be signed in to change notification settings - Fork 312
Added modules for IndexedDb #4739
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: 057dbf5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
I think this should just live in platform-browser, I can't see us adding implementations for any other platform. |
d78a6b8
to
26d36e7
Compare
* @since 1.0.0 | ||
* @category errors | ||
*/ | ||
export const IndexedDbDatabaseError = internal.IndexedDbDatabaseError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs an explicit type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the error definition for internal/exported value and type
* @since 1.0.0 | ||
* @category errors | ||
*/ | ||
export type IndexedDbQueryError = typeof internal.IndexedDbQueryError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't use internal types here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated error definition
export interface ClearAll< | ||
Source extends IndexedDbVersion.IndexedDbVersion.AnyWithProps = never | ||
> { | ||
[Symbol.iterator](): Effect.EffectGenerator<Effect.Effect<void>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the Symbol.iterator for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I simplified clearAll
and clear
to just return an Effect
instead of an intermediate interface
c05cc93
to
04d5141
Compare
04d5141
to
fb87fe1
Compare
Type
Description
Add modules for IndexedDb. This PR includes the following new modules (in order of dependency between each other):
IndexedDbTable
: define a table (withSchema
)IndexedDbVersion
: collects tables in a database versionIndexedDbMigration
: collects a sequence of versions and their schema + data migrationsIndexedDbDatabase
: service that initialises the database and executes the migrationIndexedDbQuery
: api to interact with the databaseThis also adds
BrowserIndexedDb
to@effect/platform-browser
with a layer to create an instance ofIndexedDb
from the browserwindow
.Notes
@effect/platform
since they are technically "generic" (not dependent on the browserwindow
)Note
I plan to add more examples and
README
after the PR review, to avoid having to rewrite it all because of API changesNotes for review
The modules can be reviewed in the following order (each directly depends/references the previous module):
IndexedDbTable
IndexedDbVersion
IndexedDbMigration
IndexedDbDatabase
IndexedDbQuery
IndexedDbTable
andIndexedDbVersion
don't contain any logic, they are just data containers (schemas).IndexedDbMigration
contains code to execute migrations (e.g.createObjectStore
/deleteObjectStore
).IndexedDbDatabase
is mainly used to initialise the database inside itslayer
.IndexedDbQuery
is the main service used to extract a type safe API and execute queries. The code that interacts with IndexedDb is mainly insideinternal/indexedDbQuery.ts
.IndexedDb
is a service to provide a valid instance of IndexedDb (withBrowserIndexedDb
exporting awindow
layer).