Skip to content

Installation

PgShift is organized as independent modules. Install only what you need.

PackageDescription
@pgshift/searchFull-text search via TSVector and pg_trgm
@pgshift/cacheQuery result caching via materialized views
@pgshift/queueBackground job processing via SKIP LOCKED
@pgshift/vectorSemantic and hybrid search via pgvector and HNSW indexes
@pgshift/cronRecurring job scheduling via pg_cron (requires @pgshift/queue)
@pgshift/workflowDAG-based workflow orchestration with retries and saga compensation
Terminal window
npm install @pgshift/search
npm install @pgshift/cache
npm install @pgshift/queue
npm install @pgshift/vector
npm install @pgshift/cron @pgshift/queue
npm install @pgshift/workflow
  • Node.js 20 or later
  • PostgreSQL 12 or later
  • An existing Postgres connection string

Some modules require additional Postgres extensions:

ModuleExtensionNotes
@pgshift/searchpg_trgmEnabled automatically when fuzzy: true
@pgshift/vectorpgvectorMust be installed on the Postgres server
@pgshift/cronpg_cronMust be installed on the Postgres server. Not available on all providers.

PgShift reads your connection string directly. No ORM configuration required.

const db = createClient({
url: process.env.DATABASE_URL,
})

A typical DATABASE_URL follows the format:

postgres://user:password@host:5432/database

Pass an ssl option when connecting to managed Postgres providers:

const db = createClient({
url: process.env.DATABASE_URL,
ssl: { rejectUnauthorized: false },
})

The default pool size is 10 connections. Adjust with the max option:

const db = createClient({
url: process.env.DATABASE_URL,
max: 20,
})

Always call db.destroy() on process exit to drain the connection pool cleanly.

process.on('SIGTERM', async () => {
await db.destroy()
process.exit(0)
})