evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
A utility for storing and retrieving JavaScript data types in a PostgreSQL database, demonstrating proper handling of type conversions.
The implementation should connect to PostgreSQL using the standard connection parameters (host, port, database, user, password) and handle table creation automatically.
Build a function that stores various JavaScript data types (strings, numbers, booleans, dates, arrays, and null values) into a PostgreSQL table and retrieves them back, preserving their types correctly.
Build a function that stores multiple different data types in a single database operation using parameterized queries.
/**
* Stores a value in the database with automatic type conversion.
*
* @param {any} value - The JavaScript value to store (string, number, boolean, Date, Array, null)
* @returns {Promise<any>} The retrieved value from the database
*/
async function storeAndRetrieve(value) {
// IMPLEMENTATION HERE
}
/**
* Stores multiple values in the database in a single operation.
*
* @param {Array<any>} values - Array of JavaScript values to store
* @returns {Promise<Array<any>>} Array of retrieved values from the database
*/
async function storeMultiple(values) {
// IMPLEMENTATION HERE
}
module.exports = {
storeAndRetrieve,
storeMultiple
};PostgreSQL client for Node.js with automatic type conversion support.