node-as-user-transaction
Usage
Setup (v7.0.0+)
import { transaction } from '@lanetix/as-user-transaction'
const aUT = transaction({
schema: `records,public`
dbConfig: 'something'
timeout: '42s'
shouldRetry: (err) => false
})
const asUserTransaction = (user, fn) => aUT({ user, writable: false }, fn)
asUserTransaction.writable = (user, fn) => aUT({ user, writable: true }, fn)
export default asUserTransaction
Execution (v7.0.0+)
import asUserTransaction from './curried-as-user-transaction'
const user = {}
const myResult = await asUserTransaction(user, (query, settings) => query('SELECT 1'))
console.log(myResult)
Installation
npm i -S @lanetix/as-user-transaction
Logging
This package uses debug
, so you can
log debugging things by setting DEBUG=lx-sql
or DEBUG=lx-pg-pool
to enable
logs for the sql being executed and logs for the connection pool, respectively.