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

@ormx/filters

v0.1.6

Published

Unified query filtering across Prisma, Drizzle, and Supabase

Readme

@ormx/filters

Unified query filtering across Prisma, Drizzle, and Supabase.

Write your filters once using a common format, then convert them to the native format for your ORM or database client.

Installation

npm install @ormx/filters
# or
bun add @ormx/filters

For Drizzle support, you also need drizzle-orm:

npm install drizzle-orm

Usage

Define filters using the common format

import type { QueryFilters } from "@ormx/filters";

type User = {
  id: number;
  name: string;
  email: string;
  age: number;
  status: string;
};

const filters: QueryFilters<User> = {
  where: {
    name: { Contains: "john" },
    age: { GTE: 18, LTE: 65 },
    status: { Is: "active" },
  },
};

Convert to Prisma

import { buildPrismaFilters, buildPrismaWhere } from "@ormx/filters";

// Build full filters
const prismaQuery = buildPrismaFilters(filters);
// { where: { name: { contains: "john" }, age: { gte: 18, lte: 65 }, status: { equals: "active" } } }

const users = await prisma.user.findMany(prismaQuery);

// Or build just the where clause
const where = buildPrismaWhere(filters.where);

Convert to Supabase

import { buildSupabaseFilters, buildSupabaseWhere } from "@ormx/filters";

const query = supabase.from("users").select();

// Build full filters
const filteredQuery = buildSupabaseFilters(query, filters);

// Or build just the where clause
const whereQuery = buildSupabaseWhere(query, filters.where);

const { data: users } = await filteredQuery;

Convert to Drizzle

import { buildDrizzleFilters, buildDrizzleWhere } from "@ormx/filters";
import { getTableColumns } from "drizzle-orm";
import { users } from "./schema";

const columns = getTableColumns(users);
const getColumn = (field: string) => columns[field as keyof typeof columns];

// Build full filters
const { where } = buildDrizzleFilters(filters, getColumn);

// Or build just the where clause
const whereClause = buildDrizzleWhere(filters.where, getColumn);

const result = await db.select().from(users).where(where);

Operators

| Operator | Description | Prisma | Supabase | Drizzle | | ------------ | ------------------------------ | ------------- | --------- | ------------ | | Is | Equals | equals | eq | eq | | IsNot | Not equals | not | neq | ne | | GT | Greater than | gt | gt | gt | | GTE | Greater than or equal | gte | gte | gte | | LT | Less than | lt | lt | lt | | LTE | Less than or equal | lte | lte | lte | | In | Value in array | in | in | inArray | | NotIn | Value not in array | notIn | not.in | notInArray | | Contains | Contains substring (case-insensitive) | contains | ilike | ilike | | StartsWith | Starts with (case-insensitive) | startsWith | ilike | ilike | | EndsWith | Ends with (case-insensitive) | endsWith | ilike | ilike | | IsNull | Is null | equals: null| is.null | isNull | | IsNotNull | Is not null | not: null | not.is.null | isNotNull |

OR Conditions (OneOf)

Use OneOf to create OR conditions:

const filters: QueryFilters<User> = {
  where: {
    age: { GTE: 18 },
    OneOf: [
      { status: { Is: "active" } },
      { role: { Is: "admin" } },
    ],
  },
};

This translates to: age >= 18 AND (status = 'active' OR role = 'admin')

Tree-shakeable Imports

Import only what you need:

// Full filters for each ORM
import { buildPrismaFilters } from "@ormx/filters/prisma";
import { buildSupabaseFilters } from "@ormx/filters/supabase";
import { buildDrizzleFilters } from "@ormx/filters/drizzle";

// Just the where builders
import { buildPrismaWhere } from "@ormx/filters/where/prisma";
import { buildSupabaseWhere } from "@ormx/filters/where/supabase";
import { buildDrizzleWhere } from "@ormx/filters/where/drizzle";

License

MIT