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

@vorsteh-queue/adapter-prisma

v0.4.0

Published

Prisma ORM adapter for Vorsteh Queue with PostgreSQL support

Downloads

53

Readme

@vorsteh-queue/adapter-prisma

Prisma ORM adapter for Vorsteh Queue supporting PostgreSQL databases.

Features

  • PostgreSQL Support: Full PostgreSQL compatibility with Prisma ORM
  • Type Safety: Full TypeScript support with Prisma Client
  • SKIP LOCKED: Concurrent job processing without lock contention using raw SQL
  • JSON Payloads: Complex data structures with proper serialization
  • UTC-First: All timestamps stored as UTC for reliable timezone handling

Requirements

  • Node.js 20+
  • PostgreSQL 12+ (for SKIP LOCKED support)
  • ESM only - This package is ESM-only and cannot be imported with require()

Installation

npm install @vorsteh-queue/adapter-prisma @prisma/client
# or
pnpm add @vorsteh-queue/adapter-prisma @prisma/client

Note: Make sure your project has "type": "module" in package.json or use .mjs file extensions.

Usage

import { PrismaClient } from "@prisma/client"

import { PostgresPrismaQueueAdapter } from "@vorsteh-queue/adapter-prisma"
import { Queue } from "@vorsteh-queue/core"

// Setup Prisma client
const prisma = new PrismaClient()

interface EmailPayload {
  to: string
  subject: string
  body: string
}

interface EmailResult {
  messageId: string
  sent: boolean
}

// Create adapter and queue
const adapter = new PostgresPrismaQueueAdapter(prisma)
const queue = new Queue(adapter, { name: "my-queue" })

// Register job handlers
queue.register<EmailPayload, EmailResult>("send-email", async (job) => {
  console.log(`Sending email to ${job.payload.to}`)

  // Send email logic here
  // await sendEmail(job.payload)

  return {
    messageId: "msg_123",
    sent: true,
  }
})

// Add jobs
await queue.add("send-email", {
  to: "[email protected]",
  subject: "Welcome!",
  body: "Welcome to our service!",
})

// Start processing
queue.start()

Schema Setup

Add the queue jobs table to your Prisma schema:

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

datasource db {
  provider = "postgresql"
  url      = env("DATABASE_URL")
}

// Your existing models
model User {
  id   Int    @id @default(autoincrement())
  name String
  // ... your fields
}

// Queue jobs table
model QueueJob {
  id           String    @id @default(dbgenerated("gen_random_uuid()")) @db.Uuid
  queueName    String    @map("queue_name") @db.VarChar(255)
  name         String    @db.VarChar(255)
  payload      Json
  status       String    @db.VarChar(50)
  priority     Int
  attempts     Int       @default(0)
  maxAttempts  Int       @map("max_attempts")
  createdAt    DateTime  @default(dbgenerated("timezone('utc', now())")) @map("created_at") @db.Timestamptz
  processAt    DateTime  @map("process_at") @db.Timestamptz
  processedAt  DateTime? @map("processed_at") @db.Timestamptz
  completedAt  DateTime? @map("completed_at") @db.Timestamptz
  failedAt     DateTime? @map("failed_at") @db.Timestamptz
  error        Json?
  progress     Int?      @default(0)
  cron         String?   @db.VarChar(255)
  repeatEvery  Int?      @map("repeat_every")
  repeatLimit  Int?      @map("repeat_limit")
  repeatCount  Int       @default(0) @map("repeat_count")

  @@index([queueName, status, priority, createdAt], map: "idx_queue_jobs_status_priority")
  @@index([processAt], map: "idx_queue_jobs_process_at")
  @@map("queue_jobs")
}
# Generate Prisma client and run migrations
npx prisma generate
npx prisma db push
# or
npx prisma migrate dev

Performance Notes

This adapter uses raw SQL with SKIP LOCKED for critical job selection operations to prevent race conditions in concurrent processing scenarios. Regular Prisma operations are used for other database interactions.

Testing

pnpm test

License

MIT License - see LICENSE file for details.