express-knex-transaction
Express middleware that adds a knex transaction object as req.trx
so you can easily wrap middleware and routes in a single transaction.
Usage
Called with a valid knex object, this module returns a middleware function you can .use()
before any middleware that requires database access. It then adds a trx
property to the request object that you can use for knex.transacting()
or as a knex client.
Commit and rollback are handled based on the status code of the final response.
Example
var expressKnexTransaction = ;var express = ;var knex = {}; var app = ; app; app;