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!
Is it possible to run
IDBactions (specificallyOpNewIndex) within the upgrade needed handler?Naively when I try this, the types don't line up:
createIndex(a function I added to my local clone ofreflex-indexed-db) wraps the already availableOpNewIndexStoreOp. ButcreateObjectStorewraps aDatabaseOp, 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?
OpRunStoretoDatabaseOp* for lifting store ops intoDatabaserunTransaction(I hoped to avoid this because I'd rather create the indices imperatively rather than finding a suitable event to trigger their creation)Thanks for any guidance!