A slightly nicer interface to Postgres over node-libpq providing both sync and async operations
88
Quality
Pending
Does it follow best practices?
Impact
88%
1.20xAverage score across 10 eval scenarios
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.
@generates
/**
* 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.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-pg-nativeevals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10