evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a utility module that executes PostgreSQL queries using three different asynchronous patterns. The module should provide wrapper functions that handle callback-based, promise-based, and async/await query execution.
Executes a query and returns results via a callback function following Node.js callback convention (error-first callbacks).
Executes a query and returns a Promise that resolves with the query result.
Executes a query as an async function that can be awaited.
/**
* Executes a query using callback-based approach
* @param {Object} client - Database client connection
* @param {string} query - SQL query string
* @param {Array} values - Parameter values for the query (optional)
* @param {Function} callback - Callback function (err, result) => void
*/
function executeWithCallback(client, query, values, callback) {
// Implementation
}
/**
* Executes a query using Promise-based approach
* @param {Object} client - Database client connection
* @param {string} query - SQL query string
* @param {Array} values - Parameter values for the query (optional)
* @returns {Promise} Promise that resolves with query result or rejects with error
*/
function executeWithPromise(client, query, values) {
// Implementation
}
/**
* Executes a query using async/await approach
* @param {Object} client - Database client connection
* @param {string} query - SQL query string
* @param {Array} values - Parameter values for the query (optional)
* @returns {Promise} Promise that resolves with query result
*/
async function executeWithAsync(client, query, values) {
// Implementation
}
module.exports = {
executeWithCallback,
executeWithPromise,
executeWithAsync
};Provides native PostgreSQL database client with support for synchronous and asynchronous operations.