evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility module that executes PostgreSQL queries and formats the results based on user preferences.
The module should execute a SQL query and return results where each row is represented as an object with column names as keys.
id and name accessible by their column names @testThe module should execute a SQL query and return results where each row is represented as an array of values in column order.
The module should correctly handle queries that return multiple rows, respecting the chosen format.
id and status properties @test/**
* Executes a query with object row format (default PostgreSQL behavior).
* Returns results where each row is an object with column names as keys.
*
* @param {Object} client - Connected PostgreSQL client
* @param {string} query - SQL query string
* @param {Array} values - Parameter values for the query
* @returns {Promise<Object>} Query result with rows as objects
*/
async function executeWithObjectFormat(client, query, values) {
// IMPLEMENTATION HERE
}
/**
* Executes a query with array row format.
* Returns results where each row is an array of values in column order.
*
* @param {Object} client - Connected PostgreSQL client
* @param {string} query - SQL query string
* @param {Array} values - Parameter values for the query
* @returns {Promise<Object>} Query result with rows as arrays
*/
async function executeWithArrayFormat(client, query, values) {
// IMPLEMENTATION HERE
}
module.exports = {
executeWithObjectFormat,
executeWithArrayFormat,
};Provides PostgreSQL client functionality for Node.js, including support for configuring row result formats.