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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@geetesh911/prisma-to-drizzle-query-transformer

v0.1.7

Published

The `PrismaToDrizzleTransformer` is a utility that transforms Prisma query objects into Drizzle ORM query objects. This allows you to leverage the powerful querying capabilities of Drizzle ORM while using the familiar Prisma query syntax.

Readme

Prisma to Drizzle Query Transformer

The PrismaToDrizzleTransformer is a utility that transforms Prisma query objects into Drizzle ORM query objects. This allows you to leverage the powerful querying capabilities of Drizzle ORM while using the familiar Prisma query syntax.

Features

  • Transform Prisma where clauses: Convert complex Prisma where conditions into Drizzle ORM compatible queries.
  • Support for include and select: Handle Prisma's include and select clauses to fetch related data and specific fields.
  • Pagination: Support for take (limit) and skip (offset) for pagination.
  • Order By: Convert Prisma orderBy clauses into Drizzle ORM's sorting functions.
  • Cursor-based Pagination: Implement cursor-based pagination for efficient data retrieval.

Installation

To install the package, use npm or yarn:

npm install @geetesh911/prisma-to-drizzle-query-transformer
# or
yarn add @geetesh911/prisma-to-drizzle-query-transformer
# or
pnpm add @geetesh911/prisma-to-drizzle-query-transformer

Usage

Basic Usage

import { PrismaToDrizzleTransformer } from 'prisma-to-drizzle-query-transformer';
import { myDrizzleModel } from './my-drizzle-model';

const transformer = new PrismaToDrizzleTransformer(myDrizzleModel);

const prismaQuery = {
  where: {
    name: 'John Doe',
    age: { gt: 30 },
  },
  include: {
    posts: true,
  },
  select: {
    id: true,
    name: true,
  },
  take: 10,
  skip: 5,
  orderBy: {
    createdAt: 'desc',
  },
};

const drizzleQuery = transformer.transformQuery(prismaQuery);
console.log(drizzleQuery);

Handling where Clauses

The where clause in Prisma can be transformed to Drizzle ORM's where clause using the transformQuery method.

const prismaWhere = {
  where: {
    name: 'John Doe',
    age: { gt: 30 },
  },
};

const drizzleWhere = transformer.transformQuery(prismaWhere);
console.log(drizzleWhere);

Including Related Data

You can include related data using the include clause.

const prismaInclude = {
  include: {
    posts: true,
  },
};

const drizzleInclude = transformer.transformQuery(prismaInclude);
console.log(drizzleInclude);

Selecting Specific Fields

Use the select clause to fetch specific fields.

const prismaSelect = {
  select: {
    id: true,
    name: true,
  },
};

const drizzleSelect = transformer.transformQuery(prismaSelect);
console.log(drizzleSelect);

Pagination

You can use take and skip for pagination.

const prismaPagination = {
  take: 10,
  skip: 5,
};

const drizzlePagination = transformer.transformQuery(prismaPagination);
console.log(drizzlePagination);

Ordering Results

The orderBy clause can be used to sort results.

const prismaOrderBy = {
  orderBy: {
    createdAt: 'desc',
  },
};

const drizzleOrderBy = transformer.transformQuery(prismaOrderBy);
console.log(drizzleOrderBy);

Cursor-based Pagination

For efficient pagination, you can use cursor-based pagination.

const prismaCursor = {
  cursor: {
    id: 1,
  },
  orderBy: {
    createdAt: 'asc',
  },
};

const drizzleCursor = transformer.transformQuery(prismaCursor);
console.log(drizzleCursor);

Unsupported Features

  • where clauses within include properties are not supported. For example:
      const prismaQuery = {
          include: {
              type: {
                  where: { deletedAt: null }, # Not Supported
              },
          }
      }

Error Handling

The transformer will throw errors for unsupported operators or invalid query structures. Ensure your Prisma queries are correctly structured and supported by the transformer.

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

Buy Me a Coffee

If you enjoy using this project or want to help improve it, your support means the world! You can:

  • ⭐ Star the repository
  • 🗨️ Share feedback

License

This project is licensed under the MIT License.