(sql: string, params: any[], method: 'all' | 'execute')
| 27 | } |
| 28 | |
| 29 | async query(sql: string, params: any[], method: 'all' | 'execute') { |
| 30 | if (method === 'all') { |
| 31 | try { |
| 32 | const result = await this.db.query({ |
| 33 | text: sql, |
| 34 | values: params, |
| 35 | rowMode: 'array', |
| 36 | }); |
| 37 | |
| 38 | return { data: result.rows as any }; |
| 39 | } catch (e: any) { |
| 40 | return { error: e }; |
| 41 | } |
| 42 | } else if (method === 'execute') { |
| 43 | try { |
| 44 | const result = await this.db.query({ |
| 45 | text: sql, |
| 46 | values: params, |
| 47 | }); |
| 48 | |
| 49 | return { data: result.rows as any }; |
| 50 | } catch (e: any) { |
| 51 | return { error: e }; |
| 52 | } |
| 53 | } else { |
| 54 | return { error: 'Unknown method value' }; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | async migrations(queries: string[]) { |
| 59 | await this.db.query('BEGIN'); |
no outgoing calls
no test coverage detected