Skip to content

Map before write and after read? #1456

Answered by dfahlander
m1212e asked this question in Q&A
Discussion options

You must be logged in to vote

It's possible both via hooks and middleware.

Read mapping is easiest implemented via hook('reading'). Writes via a middleware that overrides mutate. It's a bit verbose to implement but you only need to copy the example from https://dexie.org/docs/Dexie/Dexie.use(), check if req.type === 'put' || req.type === 'add' and if the table is the target one, then replace myRequest.values = req.values.map(yourMapper)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Zetanova
Comment options

Answer selected by dfahlander
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants