(connection: Connection, databaseName: string, statement: string)
| 57 | }; |
| 58 | |
| 59 | const execute = async (connection: Connection, databaseName: string, statement: string): Promise<any> => { |
| 60 | connection.database = databaseName; |
| 61 | const client = await newPostgresClient(connection); |
| 62 | const { rows, rowCount } = await client.query(statement); |
| 63 | await client.end(); |
| 64 | |
| 65 | const executionResult: ExecutionResult = { |
| 66 | rawResult: rows, |
| 67 | affectedRows: rowCount, |
| 68 | }; |
| 69 | // For those SELECT statement, we should set the affectedRows to undefined. |
| 70 | if (executionResult.rawResult.length === rowCount) { |
| 71 | executionResult.affectedRows = undefined; |
| 72 | } |
| 73 | return executionResult; |
| 74 | }; |
| 75 | |
| 76 | const getDatabases = async (connection: Connection): Promise<string[]> => { |
| 77 | const client = await newPostgresClient(connection); |
no test coverage detected