🌳
pt0/serverF/dbF/knexKustF.mts
1import type { Knex } from 'knex'
3type QueryContext = {
4 postProcessors?: Array<(result: any) => any>
5}
7export function postProcess(this: Knex.QueryBuilder, processFn: (result: any) => any) {
8 const context = this.queryContext() || {} as QueryContext
9 context.postProcessors = context.postProcessors || []
10 context.postProcessors.push(processFn)
11 this.queryContext(context)
12 return this
15export function ptWhere(this: Knex.QueryBuilder, ...args: any[]) {
16 console.log('Custom where called with:', args)
17 // Using any to bypass type checking for the where method
18 // since we're passing through arguments dynamically
19 return (this.where as any).apply(this, args)