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

@tsbouncer/prisma

v1.0.0-preview.1

Published

TupleStore over an application-owned Prisma client. Requires Prisma 7+.

Readme

@tsbouncer/prisma

A TupleStore over an application-owned Prisma client.

Requires Prisma 7 or later. Prisma 7 moved datasource.url out of the schema file and requires a driver adapter on the client, and the latest tag of the prisma CLI is currently an 8.0 release candidate with a different, platform-oriented command set — pin to a matching stable pair.

npm i @tsbouncer/prisma @prisma/client

Setup

Copy the model into your schema. MODEL_DDL exports the same text.

// schema.prisma
generator client {
  provider = "prisma-client-js"
}

datasource db {
  provider = "postgresql"   // no `url` — that moved to prisma.config.ts
}

model TsbouncerTuple {
  id               Int    @id @default(autoincrement())
  subjectType      String
  subjectId        String
  subjectRelation  String
  relation         String
  resourceType     String
  resourceId       String
  condition        String
  context          String?

  @@unique([subjectType, subjectId, subjectRelation, relation, resourceType, resourceId, condition])
  @@index([subjectType, subjectId, relation])
  @@index([relation, resourceType, resourceId])
  @@index([resourceType, resourceId])
}

Then generate a migration and the client, and pass the client you already have:

import { prismaStore } from '@tsbouncer/prisma';

const store = prismaStore(prisma);

Prisma 7 constructs its client with a driver adapter:

import { PrismaClient } from '@prisma/client';
import { PrismaPg } from '@prisma/adapter-pg';

const prisma = new PrismaClient({ adapter: new PrismaPg({ connectionString }) });

The schema

Identical to the Kysely and Drizzle adapters, so you can switch adapters without a data migration. subjectRelation and condition are '' when absent.

Why absent values are '' and not NULL

The @@unique over the seven key fields is what makes write({ mode: 'insert' }) reject duplicates. In Postgres, NULLs compare as distinct, so a unique constraint over a NULL-containing column never fires and insert silently stops rejecting duplicates. An empty string makes the constraint mean the same thing on every provider.

The compound unique name

write({ mode: 'upsert' }) needs the name of the compound unique. Prisma exposes an unnamed @@unique([...]) under a snake_case join of the field names:

subjectType_subjectId_subjectRelation_relation_resourceType_resourceId_condition

That is the default, and it is not the same as the CamelCase name of the underlying index in the database. If you named the constraint explicitly, pass it:

prismaStore(prisma, { model: 'MyTuple', uniqueKeyName: 'my_tuple_key' });

Both model and uniqueKeyName exist because the model name is yours to choose.

Transactions

Pass a transaction client to enlist a write in the caller's transaction:

await prisma.$transaction(async (tx) => {
  await updateDocument(tx);
  await prismaStore(tx).write({ tuples: [tuple] });
});

Unlike the Drizzle adapter there is no sync-driver caveat: $transaction with an async callback is the normal Prisma 7 shape.

Notes

  • pagination is reported false: read honours limit but returns no cursor.
  • delete({ kind: 'replace' }) runs inside $transaction, so it is atomic.
  • createMany is used for insert; a key collision fails the whole batch.

License

Apache-2.0