npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@semilayer/bridge-postgres

v1.7.0

Published

SemiLayer Postgres Bridge — first-party adapter for connecting SemiLayer to PostgreSQL databases

Readme


@semilayer/bridge-postgres

First-party PostgreSQL adapter for SemiLayer — the intelligence layer for any database.

This package implements the SemiLayer Bridge interface for PostgreSQL, enabling ingest, search, similarity, and direct queries against any Postgres database (including hosted flavors like Neon, Supabase, CockroachDB, and others that speak the Postgres wire protocol).

Installation

npm install @semilayer/bridge-postgres
# or
pnpm add @semilayer/bridge-postgres

Usage

import { PostgresBridge } from '@semilayer/bridge-postgres'

const bridge = new PostgresBridge({
  url: 'postgresql://user:pass@host:5432/db',
  pool: { min: 0, max: 5 }, // optional
})

await bridge.connect()

// Paginated read with keyset cursor
const result = await bridge.read('articles', {
  limit: 100,
  cursor: undefined, // first page
})

console.log(result.rows)        // BridgeRow[]
console.log(result.nextCursor)  // string | undefined
console.log(result.total)       // total row count

// Direct query with filters
const { rows } = await bridge.query('articles', {
  where: { status: 'published', views: { $gt: 100 } },
  orderBy: [{ field: 'created_at', dir: 'desc' }],
  limit: 20,
})

await bridge.disconnect()

Schema Introspection

import { introspect, listTables } from '@semilayer/bridge-postgres'
import pg from 'pg'

const pool = new pg.Pool({ connectionString: '...' })

const tables = await listTables(pool)
const info = await introspect(pool, 'articles')
// info.columns: ColumnInfo[] with type, nullable, primaryKey

Configuration

| Option | Type | Default | Description | |--------|------|---------|-------------| | url | string | required | Postgres connection string | | pool.min | number | 0 | Minimum pool connections | | pool.max | number | 3 | Maximum pool connections |

Accepts connectionString as an alias for url.

Query Operators

The query() method supports MongoDB-style operators in the where clause:

| Operator | SQL | Example | |----------|-----|---------| | $eq | = | { status: { $eq: 'active' } } | | $gt | > | { age: { $gt: 18 } } | | $gte | >= | { score: { $gte: 50 } } | | $lt | < | { age: { $lt: 65 } } | | $lte | <= | { score: { $lte: 100 } } | | $in | = ANY(...) | { status: { $in: ['a', 'b'] } } |

Bare values default to $eq: { status: 'active' } is equivalent to { status: { $eq: 'active' } }.

Incremental Ingest

read() supports changedSince for incremental reads, tracking a configurable column (default updated_at):

await bridge.read('articles', {
  changedSince: new Date('2026-01-01'),
  changeTrackingColumn: 'modified_at', // optional
  limit: 1000,
})

If the column does not exist on the table, the changedSince filter is silently dropped and a full read is performed.

Requirements

  • Node.js 20+
  • PostgreSQL 13+ (any version supported by the pg driver)
  • @semilayer/core (peer-compatible version)

Compliance Testing

This package passes the SemiLayer bridge compliance suite:

import { createBridgeTestSuite } from '@semilayer/bridge-sdk'
import { PostgresBridge } from '@semilayer/bridge-postgres'

createBridgeTestSuite(
  () => new PostgresBridge({ url: process.env.DATABASE_URL! }),
)

See CONTRIBUTING.md for details on running tests.

Links

License

MIT © SemiLayer