CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pg-native

A slightly nicer interface to Postgres over node-libpq providing both sync and async operations

88

1.20x

Quality

Pending

Does it follow best practices?

Impact

88%

1.20x

Average score across 10 eval scenarios

Overview
Eval results
Files

task.mdevals/scenario-6/

Database Connection with Keep-Alive

A Node.js module that creates a PostgreSQL database connection with TCP keep-alive configuration to maintain connectivity over long periods.

Capabilities

Creates client with keep-alive configuration

  • Creates a client with TCP keep-alive enabled and initial delay set to 45000 milliseconds @test
  • The client successfully connects to a database at localhost:5432 with user 'testuser', password 'testpass', and database 'testdb' @test

Executes queries over persistent connection

  • Executes a SELECT query "SELECT 1 as value" and returns result with rows array containing one object with value property equal to 1 @test

Implementation

@generates

API

/**
 * Creates and returns a PostgreSQL client configured with TCP keep-alive.
 *
 * @param {Object} config - Database connection configuration
 * @param {string} config.host - Database host
 * @param {number} config.port - Database port
 * @param {string} config.user - Database user
 * @param {string} config.password - Database password
 * @param {string} config.database - Database name
 * @param {number} config.keepAliveInitialDelayMillis - TCP keep-alive initial delay in milliseconds
 * @returns {Object} Configured PostgreSQL client instance
 */
function createClient(config) {
  // IMPLEMENTATION HERE
}

module.exports = {
  createClient
};

Dependencies { .dependencies }

pg { .dependency }

Provides PostgreSQL database connectivity with TCP keep-alive support.

Install with Tessl CLI

npx tessl i tessl/npm-pg-native

tile.json