Skip to content

Running IDB actions on upgradeNeeded #5

@imalsogreg

Description

@imalsogreg

Is it possible to run IDB actions (specifically OpNewIndex) within the upgrade needed handler?

Naively when I try this, the types don't line up:

  db <- ReflexIDB.indexedDb myOpenRequest $ do
    objStore <- ReflexIDB.createObjectStore storeName Nothing
    ReflexIDB.createIndex objStore ("oid", "oid", Nothing)

createIndex (a function I added to my local clone of reflex-indexed-db) wraps the already available OpNewIndex StoreOp. But createObjectStore wraps a DatabaseOp, so they aren't operations from the same monad.

What would you suggest for a path forward, if my goal is just to create these indices?

  • Add a OpRunStore to DatabaseOp* for lifting store ops into Database
  • Do my index creation inside runTransaction (I hoped to avoid this because I'd rather create the indices imperatively rather than finding a suitable event to trigger their creation)
  • Something else?

Thanks for any guidance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions