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

@routier/postgres-plugin-core

v0.3.2

Published

Engine-independent PostgreSQL building blocks for routier plugins: dialect, DDL, result translation, and a driver-shaped plugin base. Contains no database client.

Readme

@routier/postgres-plugin-core

The PostgreSQL half of Routier's SQL plugins, with no database client in it. @routier/postgresql-plugin runs this over node-postgres; @routier/pglite-plugin runs the same code over PGlite in WebAssembly.

This package is a building block for plugin authors. Application code does not import it — install the plugin for the engine you use.

What it provides

| Export | Purpose | |---|---| | PostgresDbPluginBase | A complete IDbPlugin, minus the engine. Construct it with a driver. | | PostgresDriver, PostgresConnection | The four operations a PostgreSQL engine has to supply | | compiledSchemaToPostgresTable(schema, tableName, vectors) | CREATE TABLE and its indexes, including vector(n) columns | | buildFromQueryOperation, buildJoinQueryOperation | A SELECT and its parameters, from a Routier query | | buildFromPersistOperation | Grouped INSERT/UPDATE/DELETE with RETURNING | | PostgresSqlTranslator | Result translation, with the pushdown decisions the builder made | | PostgresVectorSupport, NO_VECTOR_SUPPORT | Whether pgvector is usable, decided once per plugin |

Writing a driver

import { PostgresDbPluginBase, PostgresDriver } from "@routier/postgres-plugin-core";

const driver: PostgresDriver = {
  name: "my-engine",
  databaseName: "postgres://host:5432/app",
  async connect() {
    const client = await pool.acquire();
    return {
      all: (sql, params) => client.query(sql, params).then((r) => r.rows),
      run: (sql, params) => client.query(sql, params).then(() => undefined),
      release: async () => client.release(),
    };
  },
  dispose: () => pool.drain(),
};

class MyDbPlugin extends PostgresDbPluginBase {
  constructor() {
    super(driver);
  }
}

Transactions are not part of the interface. Every engine behind it is PostgreSQL, so BEGIN, SAVEPOINT and ROLLBACK TO SAVEPOINT are ordinary statements the plugin issues through run.

An engine with one connection may delay connect until the previous connection is released. The plugin never holds one connection while asking for another, so serialising there cannot deadlock.

Behaviour the base plugin supplies

  • Tables are created lazily on first use, and a write recovers from 42P01 inside its transaction by rolling back to a savepoint, creating the table, and retrying.
  • A concurrent creator (42P07, 23505) is absorbed rather than failing the save.
  • pgvector is probed once per plugin instance. Without it a s.vector() property is stored as JSONB and the similarity search runs in memory.
  • A token-checked UPDATE that matches no row raises OptimisticConcurrencyError.
  • Joins are pushed down, and refused rather than answered wrongly when a filter has no column.

License

MIT