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

oor

v1.6.0

Published

Query core for suffix, condition, schema, and date helpers with ES, SQL builders, and a Drizzle table plugin.

Readme

OOR

oor is a small query core for TypeScript.

It focuses on:

  • suffix parse
  • query -> condition
  • schema check with zod
  • Elasticsearch body build
  • PostgreSQL / SQLite / MySQL syntax-only builders
  • UTC date helpers

It does not manage database links, CRUD runtime, ORM adapters, or provider state.

Install

pnpm add oor

Exports

Root oor only exports the abstract query core.

  • suffix: SUFFIX, parse
  • date: toDate, hourStart, hourEnd, dayStart, dayEnd, monthStart, monthEnd, yearStart, yearEnd, dayRange, monthRange, yearRange
  • condition: makeNode, withSoft, page, sort, sortDir
  • schema: schema, read

Common types:

  • QueryInput, Node, Atom, QueryMeta, SoftRule
  • FieldKind, Suffix, Op, SortDir

Concrete builders live on subpaths:

  • oor/es: esQuery, esNode, esBody, esBodyNode, terms, dateGroup, range, avg, sum, min, max, unique
  • oor/pg: whereSql, whereNode, querySql, queryNode
  • oor/sqlite: whereSql, whereNode, querySql, queryNode
  • oor/mysql: whereSql, whereNode, querySql, queryNode
  • oor/drizzle: withTable

Suffix

Use short, readable suffix names.

  • no suffix: status=active
  • text: titleLike, titleStartWith, titleEndWith
  • list: idIn, idNotIn
  • compare: ageMin, ageMax, scoreMore, scoreLess
  • range: createdAtBetween
  • date range: createdAtDay, createdAtMonth, createdAtYear
  • date edge: createdAtHourStart, createdAtHourEnd, createdAtDayStart, createdAtDayEnd, createdAtMonthStart, createdAtMonthEnd
  • null check: deletedAtIsNull, deletedAtNotNull

When you build Node by hand, use the same plain ops:

  • Equal
  • Not
  • More
  • MoreEqual
  • Less
  • LessEqual
  • Like
  • StartWith
  • EndWith
  • In
  • NotIn
  • Between
  • IsNull
  • NotNull

Parse

import { parse } from 'oor'

const rules = parse({
  idIn: '1,2,3',
  createdAtDay: '2026-04-07',
  titleStartWith: 'oor'
})

Condition

import { makeNode } from 'oor'

const node = makeNode(
  {
    ageMin: 18,
    statusIn: ['active', 'pending']
  },
  {
    soft: {
      mode: 'flag',
      field: 'isDeleted',
      del: true,
      keep: false
    }
  }
)

Schema

import { z } from 'zod'
import { read, schema } from 'oor'

const query = schema({
  id: z.number(),
  title: z.string(),
  createdAt: z.date()
})

const params = query.parse({
  titleLike: 'oor',
  createdAtDay: '2026-04-07',
  page: '2',
  size: '10',
  sort: 'createdAt',
  order: 'desc'
})

const same = read(
  {
    id: z.number(),
    title: z.string()
  },
  { titleLike: 'oor' }
)

ES

import { avg, dateGroup, esBody, terms } from 'oor/es'

const body = esBody(
  {
    status: 'active',
    page: 2,
    size: 10,
    sort: 'createdAt',
    order: 'desc'
  },
  {
    sort: { field: 'createdAt', by: 'desc' }
  },
  {
    map: {
      status: 'status.keyword',
      createdAt: 'created_at',
      price: 'price_cents'
    },
    sortMap: {
      createdAt: 'created_at'
    },
    track: true,
    groups: {
      byStatus: terms('status', {
        size: 10,
        aggs: {
          byMonth: dateGroup('createdAt', {
            calendar: 'month'
          })
        }
      }),
      averagePrice: avg('price')
    }
  }
)

SQL

import { querySql } from 'oor/mysql'

const query = querySql(
  {
    ageMin: 18,
    nameLike: 'john',
    page: 2,
    size: 5,
    sort: 'createdAt',
    order: 'desc'
  },
  {
    soft: {
      mode: 'flag',
      field: 'isDeleted',
      del: true,
      keep: false
    }
  },
  {
    map: {
      age: { column: 'users.age', type: 'number' },
      name: { column: 'users.name', type: 'string' },
      createdAt: { column: 'users.created_at', type: 'date' },
      isDeleted: { column: 'users.is_deleted', type: 'boolean' }
    }
  }
)

oor/pg, oor/sqlite, and oor/mysql use the same API shape. They only build syntax and never open a database link.

Drizzle

If you use Drizzle and want a table-level api, use oor/drizzle instead of low-level SQL builders.

import { withTable } from 'oor/drizzle'

const userApi = withTable(db, users, {
  page: { size: 20 },
  sort: { field: 'createdAt', by: 'desc' }
})

oor/drizzle keeps its source flat under drizzle/*.ts.

  • table api entry: drizzle/index.ts
  • shared drizzle types: drizzle/type.ts
  • read/write helpers: drizzle/read.ts, drizzle/write.ts
  • write methods must include a condition
  • complex write filters use updateNode, deleteNode, and hardDeleteNode

Date

import { dayRange, toDate } from 'oor'

const date = toDate('2026-04-07')
const [start, end] = dayRange(date)

Design

  • no src
  • root exports abstract core only
  • package layout is split by role:
  • core: condition, suffix, schema, sql, type
  • adapter: es, pg, mysql, sqlite
  • utils: shared helpers such as date.ts
  • drizzle: flat Drizzle plugin files, with shared types in drizzle/type.ts
  • typeorm: reserved integration slot
  • dialect builders use subpaths
  • Drizzle table api lives in oor/drizzle
  • query core only
  • SQL is syntax only
  • runtime belongs in app code or integration packages