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

@newcms/query-engine

v0.2.0

Published

Declarative query engine for NewCMS — type-safe content queries with taxonomy, meta, and date sub-queries

Downloads

414

Readme

@newcms/query-engine

Declarative, type-safe query engine for NewCMS. Build complex content queries with taxonomy, meta, and date sub-queries — all compiled to efficient SQL via Drizzle ORM.

Installation

npm install @newcms/query-engine @newcms/database

Quick Start

import { createConnection } from '@newcms/database';
import { QueryEngine } from '@newcms/query-engine';

const { db } = createConnection();
const engine = new QueryEngine(db);

// Get published posts, newest first
const result = await engine.query({
  postType: 'post',
  postStatus: 'publish',
  perPage: 10,
  page: 1,
});

console.log(result.posts);       // Post[]
console.log(result.total);       // Total matching posts
console.log(result.totalPages);  // Total pages
console.log(result.flags);       // { isHome, isSingle, isArchive, ... }

Query Parameters

const result = await engine.query({
  // Content type
  postType: 'post',              // string or string[]
  postStatus: 'publish',         // string or string[]

  // Filters
  author: 1,                     // number or number[]
  search: 'hello world',         // full-text search
  slug: 'my-post',               // string or string[]
  parent: 0,                     // for hierarchical types
  include: [1, 2, 3],            // only these IDs
  exclude: [4, 5],               // not these IDs

  // Pagination
  perPage: 10,                   // -1 for all results
  page: 1,

  // Ordering
  orderBy: 'date',               // date | title | name | modified | id | author | menu_order
  order: 'desc',                 // asc | desc
});

Taxonomy Sub-Query

Filter posts by assigned terms:

const result = await engine.query({
  tax: {
    relation: 'AND',  // all clauses must match
    clauses: [
      { taxonomy: 'category', termSlugs: ['news', 'tech'], operator: 'IN' },
      { taxonomy: 'post_tag', termIds: [42], operator: 'IN' },
    ],
  },
});

Operators:

  • IN — post has any of the specified terms (default)
  • NOT IN — post does NOT have any of the specified terms
  • AND — post has ALL specified terms

Meta Sub-Query

Filter posts by metadata values:

const result = await engine.query({
  meta: {
    relation: 'AND',
    clauses: [
      { key: '_featured', compare: 'EXISTS' },
      { key: 'rating', value: 4, compare: '>=', type: 'NUMERIC' },
      { key: 'color', value: 'red', compare: '=' },
    ],
  },
});

Compare operators: =, !=, >, <, >=, <=, LIKE, NOT LIKE, IN, NOT IN, EXISTS, NOT EXISTS

Type casting: CHAR (default), NUMERIC, DATE, DATETIME

Date Sub-Query

Filter posts by date:

const result = await engine.query({
  date: {
    relation: 'AND',
    clauses: [
      { year: 2026, month: 4 },
      { after: '2026-01-01', before: '2026-12-31' },
      { column: 'post_modified' },  // default: post_date
    ],
  },
});

Query Flags

Every result includes flags indicating the query type:

result.flags.isHome      // Default blog listing
result.flags.isSingle    // Single post/page
result.flags.isArchive   // Archive (author, taxonomy, date)
result.flags.isSearch    // Search results
result.flags.is404       // No results found
result.flags.isPage      // Page type query
result.flags.isAuthor    // Author archive
result.flags.isTaxonomy  // Taxonomy archive
result.flags.isDate      // Date archive

Single Post Query

const result = await engine.querySingle(42);
// Queries post ID 42 with status publish/private/draft

License

GPL-2.0-or-later