-
-
Notifications
You must be signed in to change notification settings - Fork 15
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
As per #303, we have an option to override log settings inside a certain (sub-)transaction. I believe this is incorrect coupling; I am now in need to disable logging for a certain execution path without having to use transactions.
I propose to decouple log option from transaction AsyncLocalStorage to an individual local storage with its own life cycle, and something like
await db.withOptions({ log: true}, async () => {
// all queries will be logged here
})This has a potential to store more options. For example, as I elaborated in #642, it would be great to have a wrapper that binds db.options.schema into unbound raw-sql refs. Then, we could do:
await db.withOptions({ schema: currentTenant.schema }, async () => {
await doWork()
})
async function doWork() {
// this will automatically fetch from `tenant.table`
await db.query`SELECT * FROM ${db.ref('table')}`
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request