Getting Started
PgShift is an open source infrastructure toolkit for Node.js applications backed by PostgreSQL.
Search, caching, queues, cron jobs, and realtime — all inside the Postgres instance you already run. No new services to provision. No new credentials to manage.
Requirements
Section titled “Requirements”- Node.js 20 or later
- PostgreSQL 12 or later
Install
Section titled “Install”Install the module you need. Each module ships with its Postgres adapter included.
npm install @pgshift/searchnpm install @pgshift/vectorConfigure
Section titled “Configure”Each module exposes a createClient function. Pass your Postgres connection string and you are ready.
import { createClient } from '@pgshift/search'
const db = createClient({ url: process.env.DATABASE_URL })Run your first search
Section titled “Run your first search”import { createClient } from '@pgshift/search'
const db = createClient({ url: process.env.DATABASE_URL })
// Create the search index for an entity. Idempotent, safe to call on every startup.await db.search('products').index({ fields: ['name', 'description', 'category'], weights: { name: 'A', description: 'B', category: 'C' }, fuzzy: true,})
// Index a documentawait db.search('products').upsert('1', { name: 'Nike Air Max 90', description: 'Classic sneaker with visible Air unit.', category: 'shoes',})
// Searchconst results = await db.search('products').query('air max', { fuzzy: true, filters: { category: 'shoes' }, limit: 10,})
console.log(results)// [{ id: '1', rank: 0.626, data: { name: 'Nike Air Max 90', ... } }]
// Drain connections on shutdownawait db.destroy()Next steps
Section titled “Next steps”- Search module — full API reference
- Cache module — materialized view caching
- Queue module — background job processing
- Cron module — recurring job scheduling
- Migration Hints — how PgShift tells you when to move on