MCPcopy Create free account
hub / github.com/dynajoe/tinypg / sql

Method sql

src/tiny.ts:99–117  ·  view source on GitHub ↗
(name: string, params?: P)

Source from the content-addressed store, hash-verified

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()

Callers 7

transactions.tsFile · 0.80
thisShouldBeInStackFunction · 0.80
select.tsFile · 0.80
thisShouldBeInStackFunction · 0.80
fnFunction · 0.80
hooks.tsFile · 0.80
createAndQueryCustomerFunction · 0.80

Calls 2

makeHooksLifeCycleMethod · 0.95
performDbCallMethod · 0.95

Tested by

no test coverage detected