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

prisma-ydb

v0.1.0-rc.9

Published

Native YDB driver, Prisma ORM 8 target and migrations

Readme

prisma-ydb

Native YDB driver, ORM target and migrations for Prisma ORM 8. ESM, Node ^24.11.0 || >=26.0.0. Pinned to Prisma CLI 8.0.0-rc.24, ORM platform packages 8.0.0-rc.18, and YDB JS SDK 6.3.1.

This integration uses the Prisma 8 SQL-family API: db.orm.Task, reusable fragments and generated contracts. The pinned release-candidate integration needs qualification against your deployment workload.

Install

After publication:

yarn add prisma-ydb@next @prisma/[email protected] @prisma/[email protected]
yarn add -D [email protected]

Before publication, replace prisma-ydb@next with the .tgz from the source workspace's yarn package:pack. Explicit platform dependencies also let Prisma choose public imports for generated TypeScript declarations.

Configure

prisma.config.ts:

import { definePrismaConfig } from 'prisma/config';
import { defineYdbConfig } from 'prisma-ydb/config';
import { ydbBindingFromEnv } from 'prisma-ydb/environment';

export default definePrismaConfig({
  orm: defineYdbConfig({
    contract: './prisma/contract.prisma',
    relationMode: 'application',
    output: './src/generated',
    migrations: { dir: './prisma/migrations' },
    db: { connection: ydbBindingFromEnv() },
  }),
});

Set YDB_CONNECTION_STRING=grpc://localhost:2137/local locally, or the cluster's grpcs:// endpoint/database path. Load .env in your process if used, for example with import 'dotenv/config' after installing dotenv. Authentication and TLS use the official SDK environment provider.

prisma/contract.prisma:

// use prisma-8
model Task {
  id        String   @id @default(uuid())
  title     String
  done      Boolean  @default(false)
  createdAt temporal.createdAt()
}
yarn prisma contract emit
yarn prisma migration plan --name init
yarn prisma migration check
yarn prisma db migrate
yarn prisma db verify

Commit schema, migrations and their snapshots. Regenerate client contracts during build.

Query and transact

import { ydb, Text } from 'prisma-ydb/runtime';
import { ydbBindingFromEnv } from 'prisma-ydb/environment';
import type { Contract } from './generated/contract.d.js';
import contractJson from './generated/contract.json' with { type: 'json' };

const db = ydb<Contract>({ contractJson, binding: ydbBindingFromEnv() });
await db.connect();
try {
  const summary = db.orm.Task.fragment((tasks) =>
    tasks.select('id', 'title', 'done'),
  );
  const task = await db.transaction(
    async (tx) => {
      const created = await tx.orm.Task.create({
        title: 'YDB',
      });
      await tx.yql(
        'DECLARE $id AS Utf8; UPDATE `Task` SET done = TRUE WHERE id = $id',
        { id: new Text(created.id) },
      );
      return tx.orm.Task.with(summary).where({ id: created.id }).first();
    },
    { retry: true },
  );
  console.log(task, await db.health(), db.stats());
} finally {
  await db.close();
}

Retries repeat the whole callback; external side effects must tolerate repetition. Unknown commit outcomes require reconciliation. Values travel as parameters.

| Entry point | Purpose | | ------------------------ | ------------------------------------------------- | | prisma-ydb | Factory, public types and native driver | | prisma-ydb/runtime | ORM factory, codecs and typed YQL values | | prisma-ydb/driver | Native driver, transactions, errors and streaming | | prisma-ydb/config | Official Prisma CLI configuration | | prisma-ydb/control | Migration authoring and control plane | | prisma-ydb/environment | SDK environment authentication/TLS |

Native UUIDs and prepared reads

Author UUID columns as Uuid, nullable UUIDs as Uuid?, and keep UUID DTO properties as string. Native UUID primary keys (including composite keys) and synchronous unique indexes retain the 128-bit identity. Inputs accept uppercase hex and normalize to lowercase. Native YQL can use validated new UuidValue(id) from prisma-ydb/runtime; optional, list and struct containers preserve that type. The existing Uuid export keeps the SDK primitive API. Native UUID ordering is YDB byte order, so use server ordering and seek comparisons together.

await db.prepare(declaration, callback) returns a reusable prepared handle. Execute it with prepared.query(db, params), or prepared.query(tx, params) inside a live db.transaction callback. A runtime intermediary is unnecessary. See types and native YQL and shared selections.

String enums

Enums declared in .prisma generate literal types for writes, filters and query results. Their values are stored as YDB Utf8:

enum TaskStatus {
  TODO
  DOING
  DONE
}

Add status TaskStatus @default(TODO) to a model and regenerate the contract. Use db.enums.TaskStatus.members.TODO (or tx.enums.TaskStatus.members.TODO in a transaction). typeof db.enums.TaskStatus.Value gives the value type; db.enums.TaskStatus.has(value) validates external input and narrows its type. Membership is not automatically checked on reads or writes. Explicit stored strings use TODO = "todo". See the enum API guide.

Guides

Native temporal.* presets provide automatic timestamps. Schema types include Decimal(p, s), calendar Date and microsecond Timestamp; scalar/enum lists and typed nested value objects use Json storage with JSON-path/list filters. See the type and query API. Client-side referential actions support Cascade, SetNull and Restrict. Schema TTL policies, @@partitioning and @@changefeed settings are planned, applied and introspected through the migration workflow. Changefeed declarations own topic retention, partitioning and consumer names; verification detects drift and migration checkpoints cover each table/feed/consumer DDL. Explicit uniform/topic partition counts require an unsigned-leading key. See the migration guide for destructive feed recreation rules. Raw YQL writes bypass automatic timestamps and referential actions.

Start with the documentation index. Detailed guides cover relations and referential integrity, migrations, transactions and retries, native YQL, selections and DTOs, NestJS, operations and the API.

Integration checks

In the source workspace, yarn check validates the library and basic example offline. Set YDB_CONNECTION_STRING to an empty, disposable local database and run yarn test:integration for the sequential Node 24 integration suite. The fixtures clean up their own tables and feeds; migration fixtures also own and remove the control metadata they created. The runner fails when the endpoint is missing.