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

@doccop/storage-postgres

v0.2.0

Published

Postgres reference implementation of doccop store interfaces (Drizzle ORM)

Readme

@doccop/storage-postgres

Drizzle-ORM-backed reference implementations of every @doccop/server store interface, plus a filesystem-backed StorageAdapter for blob persistence. Hosts running on Postgres can drop these in directly; others use them as a porting target.

Status: 0.2.0-beta.0 — feature-frozen for the 0.2.0 line.

Install

npm install @doccop/storage-postgres @doccop/server @doccop/core drizzle-orm postgres

All dependencies pinned exactly to keep the cross-package interface contract intact.

Wire it up

import { drizzle } from "drizzle-orm/postgres-js";
import postgres from "postgres";
import * as doccop from "@doccop/storage-postgres";

const sql = postgres(process.env.DATABASE_URL!);
const db = drizzle(sql, { schema: doccop.schema });

const config = {
  // Engine deps (from @doccop/core) go here:
  storage: new doccop.FilesystemBlobStorage({ rootDir: "./blobs" }),
  resolvers: [/* your EntityResolvers */],
  // ...

  // Stores from this package:
  templates: new doccop.PostgresTemplateStore(db),
  templateVersions: new doccop.PostgresTemplateVersionStore(db),
  snippets: new doccop.PostgresSnippetStore(db),
  snippetVersions: new doccop.PostgresSnippetVersionStore(db),
  documents: new doccop.PostgresDocumentStore(db),
  idempotency: new doccop.PostgresIdempotencyStore(db),
  dataTypes: new doccop.PostgresDataTypeRegistry(db),
};

Apply the schema

The package ships an idempotent migration:

psql "$DATABASE_URL" < node_modules/@doccop/storage-postgres/migrations/0000_init.sql

Or apply it through your existing migration runner (drizzle-kit, node-pg-migrate, sqitch — anything). All tables are prefixed doccop_ so they coexist with any host schema.

What's included

| Class | Replaces interface | |---|---| | PostgresTemplateStore | TemplateStore | | PostgresTemplateVersionStore | TemplateVersionStore | | PostgresSnippetStore | SnippetStore | | PostgresSnippetVersionStore | SnippetVersionStore | | PostgresDocumentStore | DocumentStore | | PostgresIdempotencyStore | IdempotencyStore | | PostgresDataTypeRegistry | DataTypeRegistry | | FilesystemBlobStorage | StorageAdapter (for local dev / demos) |

Production deployments typically swap FilesystemBlobStorage for an S3 / GCS / Azure Blob / Supabase Storage adapter. The StorageAdapter interface is small (8 methods); implement it against your blob store directly.

Operational notes

  • Optimistic locking: PostgresTemplateStore.setCurrentVersion uses UPDATE … WHERE current_version_id = expected. Returns null on conflict — the server maps this to 409 Conflict.
  • Idempotency cleanup: PostgresIdempotencyStore.cleanupOlderThan(date) is provided for host cron jobs. Recommended retention: 24h.
  • Connection pool: the package never opens its own connection — wire in whatever pool sizing your host uses.

Schema

Tables (all prefixed doccop_):

doccop_templates                doccop_template_versions
doccop_snippets                 doccop_snippet_versions
doccop_generated_documents      doccop_idempotency
doccop_variables                (enum doccop_visibility)

Drizzle table definitions are exported as schema.* for inclusion in your own Drizzle config.

Documentation

  • Integration guide — full adapter contract, error mapping, deployment recommendations.
  • demo-app — runnable example showing the full wiring.

License

MIT — see LICENSE.