Registry / database / leo-connector-postgres

leo-connector-postgres

JSON →
library4.0.19-betajsnpmunverified

A Node.js PostgreSQL connector for the Leo Platform, version 4.0.19-beta. Provides connection pooling, query building, and transaction support for Postgres databases within Leo Platform applications. Released as a beta, it integrates tightly with Leo Platform's service architecture. Differentiators include built-in Leo Platform compatibility and simplified query syntax.

npm install leo-connector-postgres
INSTALL
IMPORT
SIG · LEO-CONNECTOR-POST
L
leo-connector-postgres
databasejavascriptv4.0.19-beta
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

PostgresConnector
import { PostgresConnector } from 'leo-connector-postgres'
const PostgresConnector = require('leo-connector-postgres').PostgresConnector
Default import is not supported; use named import.
createConnection
import { createConnection } from 'leo-connector-postgres'
import createConnection from 'leo-connector-postgres'
Function is exported as named export, not default.
query
import { query } from 'leo-connector-postgres'
import { Query } from 'leo-connector-postgres'
Function name is lowercase 'query'.

Shows creating a Postgres connector, connecting, executing a parameterized query, and closing the connection.

import { PostgresConnector, createConnection } from 'leo-connector-postgres'; import { config } from 'leo-platform'; const connectionConfig = { host: process.env.PG_HOST ?? 'localhost', port: parseInt(process.env.PG_PORT ?? '5432'), database: process.env.PG_DATABASE ?? 'mydb', user: process.env.PG_USER ?? 'user', password: process.env.PG_PASSWORD ?? 'password', }; async function main() { const connector = new PostgresConnector(connectionConfig); await connector.connect(); const result = await connector.query('SELECT * FROM users WHERE id = $1', [1]); console.log(result.rows); await connector.close(); } main().catch(console.error);
Debug
Known issues
breakingVersion 4.x changes the API from callback-based to promise-based.
fix
Update code to use async/await instead of callbacks.
affects: >=4.0.0 <4.0.0
deprecatedThe 'pool' option is deprecated in favor of 'connectionPool' in connector config.
fix
Rename 'pool' to 'connectionPool' in config object.
affects: >=4.0.0
gotchaConnection strings are not supported; use individual config parameters.
fix
Provide host, port, database, user, and password separately.
affects: >=4.0.0
gotchaQueries must use $1, $2, etc. for parameters; ? placeholders are not supported.
fix
Use $1, $2 parameterized style.
affects: >=4.0.0
Errors
Common errors & fixes
Cannot find module 'leo-connector-postgres'
Package not installed or missing from node_modules.
fix
Run 'npm install leo-connector-postgres'.
TypeError: connector.query is not a function
Using default import instead of named import.
fix
Use 'import { PostgresConnector } from 'leo-connector-postgres''.
Error: getaddrinfo ENOTFOUND localhost
Database host not reachable or misconfigured.
fix
Check PG_HOST environment variable or connection config.
Error: password authentication failed for user
Incorrect user or password.
fix
Verify PG_USER and PG_PASSWORD environment variables.
Upgrade
Version history
4.0.19-betalatest on npm
Audit
Dependencies
pgrequiredPostgreSQL client for Node.js
Agent activity
4 hits · last 30 days
node
4
Resources
leo-connector-postgres — npm install leo-connector-postgres · libregistry