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

@skxv/query-builder

v1.1.8

Published

A flexible query builder for use with internal TC api, that generates URL query strings

Readme

@skxv/query-builder

A flexible query builder for use with internal TC api, that generates URL query strings. This package helps you build complex query strings with support for sorting, filtering, pagination, populate, select, and SQL debugging.

Installation

npm install @skxv/query-builder

Quick Start

import { queryBuilder } from "@skxv/query-builder/dist/src";

// Basic usage
const query = queryBuilder({
  // Sorting
  sort: [
    { field: "createdAt", order: "asc" },
    { field: "name", order: "desc" }
  ],

  // Filtering
  filters: [
    // Simple filter
    {
      field: "status",
      operator: "$eq",
      value: "active"
    },

    // Logical operator filter
    {
      operator: "$and",
      filters: [
        { field: "type", value: "user" },
        { field: "isVerified", value: true }
      ]
    }
  ],

  // Pagination
  pagination: {
    limit: 10,
    offset: 0
  },

  // Populate related fields
  populate: ["profile", "settings"],

  // Select specific fields
  select: ["id", "name", "email", "status"],

  // SQL Debugging
  showSql: true,
  logSql: true
});

Features

Sorting

Sort results by one or more fields:

const query = queryBuilder({
  sort: [
    { field: "createdAt", order: "asc" },
    { field: "name", order: "desc" }
  ]
});
// Results in: sort[0]=createdAt&sort[1]=name:desc

Filtering

Apply complex filters using comparison and logical operators:

const query = queryBuilder({
  filters: [
    // Simple comparison
    {
      field: "status",
      operator: "$eq",
      value: "active"
    },
    // Logical combination
    {
      operator: "$and",
      filters: [
        { field: "type", value: "user" },
        { field: "isVerified", value: true }
      ]
    }
  ]
});

Pagination

Control the number of results and pagination:

const query = queryBuilder({
  pagination: {
    limit: 10,
    offset: 20
  }
});
// Results in: pagination[limit]=10&pagination[offset]=20

Populate

Include related data in the response:

const query = queryBuilder({
  // Array of strings
  populate: ["profile", "settings"],

  // Or comma-separated string
  populate: "profile,settings,preferences"
});
// Results in: populate=profile,settings

Select

Choose specific fields to return in the response:

const query = queryBuilder({
  select: ["id", "name", "email", "status", "createdAt"]
});
// Results in: select=id,name,email,status,createdAt

Note: The id field cannot be de-selected and will always be included in the response.

SQL Debugging

Enable SQL query debugging for development:

const query = queryBuilder({
  showSql: true, // Show SQL in output
  logSql: true // Log SQL to TYPO3 system log
});
// Results in: showsql=1&logsql=1

Note: SQL debugging only works when the request originates from a local (private) IP address.

API Reference

QueryBuilderSettings

Main configuration interface:

interface QueryBuilderSettings {
  sort?: Sort[];
  filters?: (Filter | LogicalFilter)[];
  pagination?: Pagination;
  populate?: string[] | string;
  select?: string[];
  showSql?: boolean;
  logSql?: boolean;
}

Sort

interface Sort {
  field: string;
  order: "asc" | "desc";
}

Filter

interface Filter {
  field: string;
  operator?: ComparisonOperator;
  value: string | number | boolean | null | Array<string | number>;
  relation?: string;
}

ComparisonOperator

Available operators:

  • $eq: Equal
  • $gt: Greater than
  • $gte: Greater than or equal
  • $lt: Less than
  • $lte: Less than or equal
  • $in: In array
  • $null: Is null
  • $like: Wildcard search

LogicalFilter

interface LogicalFilter {
  operator: LogicalOperator; // "$and" | "$or" | "$not"
  filters: Filter[];
}

Pagination

interface Pagination {
  limit: number;
  offset?: number;
}

Advanced Examples

Complex Query with All Features

const query = queryBuilder({
  sort: [{ field: "createdAt", order: "desc" }],
  filters: [
    {
      field: "status",
      value: "active"
    },
    {
      operator: "$and",
      filters: [
        {
          field: "type",
          operator: "$eq",
          value: "user"
        },
        {
          field: "isVerified",
          operator: "$eq",
          value: true
        }
      ]
    }
  ],
  pagination: {
    limit: 100
  },
  populate: ["profile", "settings", "preferences"],
  select: ["id", "name", "email", "status", "createdAt"],
  showSql: true
});

Changelog

  • 1.1.7 - 9. April 2024

    Added support for select, and sql debugging