(name: string, params?: P)
| 97 | } |
| 98 | |
| 99 | sql<T extends object = any, P extends T.TinyPgParams = T.TinyPgParams>(name: string, params?: P): Promise<T.Result<T>> { |
| 100 | const query_id = Uuid.v4() |
| 101 | |
| 102 | const hook_lifecycle = this.makeHooksLifeCycle() |
| 103 | |
| 104 | const [, new_params] = hook_lifecycle.preSql({ query_id: query_id, transaction_id: this.transaction_id }, [name, params]).args |
| 105 | |
| 106 | return Util.stackTraceAccessor(this.options.capture_stack_trace!, async () => { |
| 107 | log('sql', name) |
| 108 | |
| 109 | const db_call: DbCall = this.sql_db_calls[name] |
| 110 | |
| 111 | if (_.isNil(db_call)) { |
| 112 | throw new Error(`Sql query with name [${name}] not found!`) |
| 113 | } |
| 114 | |
| 115 | return this.performDbCall(db_call, hook_lifecycle, new_params, query_id) |
| 116 | }) |
| 117 | } |
| 118 | |
| 119 | transaction<T = any>(tx_fn: (db: TinyPg) => Promise<T>): Promise<T> { |
| 120 | const transaction_id = Uuid.v4() |
no test coverage detected