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

typeorm-query-params-parser

v1.0.0

Published

A simple query params parser for TypeORM query builder

Readme

TypeORM Query Params Parser

A simple and flexible query parameter parser for TypeORM's QueryBuilder.

Features

  • Select specific fields and relations
  • Join relations easily
  • Sort, limit, and paginate results
  • Cache queries with custom options
  • Soft delete support (withDeleted)
  • Advanced filtering with logical and comparison operators

Installation

npm install typeorm-query-params-parser
# or
yarn add typeorm-query-params-parser

Quick Start

import { TypeORMQueryParser } from "typeorm-query-params-parser";

const query = request.query;
const queryBuilder = createQueryBuilder(Entity, "entity");
const queryParser = new TypeORMQueryParser(queryBuilder);

queryParser.parse(query);

// Continue using `queryBuilder` as needed
const results = await queryBuilder.getMany();

Documentation

Supported Query Parameters


select

Specify which fields to return. Use dot notation for nested fields.

Examples:

Select id, name, and profile.id:

{ "select": ["id", "name", "profile.id"] }

Select all fields of profile:

{ "select": ["id", "name", "profile.*"] }

relations

Left join relations. Use dot notation for nested relations.

Example:

Join profile and its photo:

{ "relations": ["profile", "profile.photo"] }

sort

Sort by one or more fields. Prefix with - for descending order.

Example:

Sort by id ascending and name descending:

{ "sort": ["id", "-name"] }

limit

Set the maximum number of items returned (default: 20).

Example:

{ "limit": 100 }

page

Specify the page number for pagination (default: 1).

Example:

{ "page": 2 }

paginate

Enable or disable pagination (default: true).

Example:

{ "paginate": false }

cache

Enable/disable cache, set cache duration (ms), or provide cache ID.

Examples:

Enable cache:

{ "cache": true }

Set cache duration:

{ "cache": 1000 }

Set cache ID and duration:

{ "cache": ["my-cache-id", 1000] }

withDeleted

Include soft-deleted entities.

Example:

{ "withDeleted": true }

filter

Advanced filtering using comparison and logical operators.

Syntax

{
  "filter": {
    "<field>": { "<operator>": "<value>" }
  }
}

Supported Operators

| Operator | Description | | -------------- | ---------------------------------------- | | _eq | Equal to | | _neq | Not equal to | | _lt | Less than | | _lte | Less than or equal to | | _gt | Greater than | | _gte | Greater than or equal to | | _in | Value is in array | | _null | Is null (true) or not null (false) | | _contains | Contains substring | | _starts_with | Starts with substring | | _ends_with | Ends with substring | | _between | Value is between two values | | _empty | Is empty (true) or not empty (false) |

Examples

Filter by name:

{
  "filter": {
    "name": { "_eq": "Erick" }
  }
}

Filter by categories:

{
  "filter": {
    "categories": { "_in": ["vegetables", "fruit"] }
  }
}

Logical Operators

Combine multiple conditions with _and or _or:

{
  "filter": {
    "_and": [
      {
        "title": { "_eq": "Readme" }
      },
      {
        "status": { "_eq": "published" }
      }
    ],
    "_or": [
      {
        "title": { "_eq": "Readme" }
      },
      {
        "status": { "_eq": "published" }
      }
    ]
  }
}

Tips

  • Use the qs package to parse nested objects into query strings.