Closed lehni closed 5 years ago
If I understand you correctly, you can use opts.ContextStore
instead of opts.store
.
ContextStore must be a class which claims three instance methods demonstrated above. new ContextStore(ctx) will be executed on every request.
@ngot you're right, that will solve it, thanks!
I have a koa middleware that handles the creation of database transactions before, and their committing / rolling back after the execution of other middlewares. The transaction object is exposed on the
ctx
object that is passed to all middlewares asctx.trx
Since the session itself is also stored in the database, it would be nice if the various custom
store
methods could receive the associatedctx
object, so this transaction could also be used to tie the session changes into the same transaction.Some of the store methods already receive a third object argument with various parameters (
changed
androlling
so far), couldctx
be added there as well? And could this argument also be passed tostore.destroy()
?If this is agreeable, I'd be happy to create a PR for it.