Registry / database / tsbean-driver-postgres

tsbean-driver-postgres

JSON →
library3.0.2jsnpmunverified

PostgreSQL driver for TSBean-ORM, based on the pg library. Current stable version is 3.0.2, released alongside tsbean-orm 3.0.0. This driver automatically handles identifier conversion from camelCase (TypeScript) to snake_case (PostgreSQL), supporting custom conversion or disabling entirely. It is designed exclusively for use with tsbean-orm as a peer dependency. The driver connects to PostgreSQL using the pg package and provides a DataSource via PostgreSQLDriver.createDataSource(). Release cadence follows tsbean-orm releases. Key differentiator: built-in identifier mapping between ORM and database naming conventions.

npm install tsbean-driver-postgres
INSTALL
IMPORT
SIG · TSBEAN-DRIVER-POST
T
tsbean-driver-postgres
databasejavascriptv3.0.2
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.

PostgreSQLDriver
✓ import { PostgreSQLDriver } from 'tsbean-driver-postgres'
✗ const PostgreSQLDriver = require('tsbean-driver-postgres')
Package is ESM-only. CommonJS require() will not work.
PostgreSQLDriver (type)
✓ import type { PostgreSQLDriver } from 'tsbean-driver-postgres'
For type-only imports when you only need the type of PostgreSQLDriver.
DataSourceDriver
✓ import { DataSourceDriver } from 'tsbean-orm'
✗ import { DataSourceDriver } from 'tsbean-driver-postgres'
DataSourceDriver is exported by tsbean-orm, not this driver package.
DataSource
✓ import { DataSource } from 'tsbean-orm'
✗ import { DataSource } from 'tsbean-driver-postgres'
DataSource is from tsbean-orm, not from the driver package.

Creates a PostgreSQL data source using connection parameters and sets it as the default data source for TSBean-ORM.

import { DataSourceDriver, DataSource } from "tsbean-orm"; import { PostgreSQLDriver } from "tsbean-driver-postgres"; // Create a PostgreSQL data source with connection options const mySource = PostgreSQLDriver.createDataSource({ host: process.env.DB_HOST ?? "localhost", port: parseInt(process.env.DB_PORT ?? "5432"), user: process.env.DB_USER ?? "postgres", password: process.env.DB_PASSWORD ?? "postgres", database: process.env.DB_NAME ?? "my_database", }); // Set as default data source for the ORM DataSource.set(DataSource.DEFAULT, mySource); console.log("PostgreSQL data source configured successfully.");
Debug
Known issues
deprecatedThe constructor PostgreSQLDriver(options) is deprecated since version 2. Use PostgreSQLDriver.createDataSource(options) instead.
fix
Replace new PostgreSQLDriver(options) with PostgreSQLDriver.createDataSource(options).
affects: >=1.0.0 <2.0.0
breakingIn version 3.0.0, the package switched from CJS to ESM-only. CommonJS require() will throw an error.
fix
Use import statements. If you need CJS, stick to version 2.x or use dynamic import().
affects: >=3.0.0
deprecatedThe option 'disableIdentifierConversion' is deprecated since version 3. Use 'disableAutoIdentifierConversion' instead.
fix
Rename 'disableIdentifierConversion' to 'disableAutoIdentifierConversion' in your data source configuration.
affects: >=2.0.0 <3.0.0
gotchaIdentifier conversion (camelCase <-> snake_case) is enabled by default. If your database uses mixed-case or unconventional identifiers, queries may fail.
fix
Set disableAutoIdentifierConversion: true in your data source config, or provide a customIdentifierConversion function.
affects: >=1.0.0
breakingNode.js engine requirement increased from >=10.0.0 to >=16.0.0 in version 3.0.0.
fix
Upgrade Node.js to version 16 or higher.
affects: >=3.0.0
Errors
Common errors & fixes
ERR_REQUIRE_ESM: require() of ES Module not supported
Package is ESM-only since version 3; using require() fails.
fix
Change require('tsbean-driver-postgres') to import { PostgreSQLDriver } from 'tsbean-driver-postgres'.
Cannot find module 'tsbean-orm'
tsbean-orm is a peer dependency and must be installed explicitly.
fix
Run 'npm install tsbean-orm' alongside tsbean-driver-postgres.
TypeError: PostgreSQLDriver is not a constructor
Using new PostgreSQLDriver() after version 2; the constructor is removed.
fix
Use PostgreSQLDriver.createDataSource(options) instead.
Error: getaddrinfo ENOTFOUND localhost
Database host is not reachable or DNS resolution fails.
fix
Check your network connection and hostname. For Docker, use 'host.docker.internal' for localhost.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
18 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources
tsbean-driver-postgres — npm install tsbean-driver-postgres · libregistry