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

@anycms/json-query

v0.1.1

Published

TypeScript SDK for anycms-sea-orm JSON query engine

Readme

@anycms/json-query

TypeScript SDK for anycms-sea-orm JSON query engine.

提供类型安全的查询构建器和通用 API 客户端,与后端 JsonQueryEngine 一一对应,支持 AND/OR 任意嵌套组合。

安装

npm install @anycms/json-query

使用

简单查询

import { QueryBuilder, createEntityApi } from '@anycms/json-query';

const query = new QueryBuilder()
  .eq('status', 1)
  .in('level', [1, 2, 3])
  .keyword('搜索关键词')
  .sort('created_time', 'desc')
  .page(1, 20)
  .build();

AND/OR 嵌套

// status=1 AND (level=1 OR level=2)
const query = new QueryBuilder()
  .eq('status', 1)
  .or(b => b.eq('level', 1).eq('level', 2))
  .build();

复杂嵌套

// (type=1 AND level>=2) OR (type=2 AND level=3)
const query = new QueryBuilder()
  .orGroup([
    b => b.eq('type', 1).gte('level', 2),
    b => b.eq('type', 2).eq('level', 3),
  ])
  .build();

范围查询

// 价格在 100~500 之间
const query = new QueryBuilder()
  .between('price', 100, 500)
  .build();

// 时间范围
const query = new QueryBuilder()
  .between('created_time', 1700000000, 1800000000)
  .build();

文本过滤

// 不包含 "spam"
const query = new QueryBuilder()
  .notContains('title', 'spam')
  .build();

// 空字符串或 NULL
const query = new QueryBuilder()
  .isEmpty('remark')
  .build();

// 非空且有内容
const query = new QueryBuilder()
  .isNotEmpty('remark')
  .build();

通用实体 API 客户端

const customerApi = createEntityApi<Customer>('/api/customer');

// JsonQuery 查询
const result = await customerApi.query(
  new QueryBuilder().eq('status', 1).page(1, 20).build()
);

// CRUD
await customerApi.create({ name: 'New' });
await customerApi.get('id');
await customerApi.update('id', { name: 'Updated' });
await customerApi.delete('id');

API 参考

QueryBuilder

| 方法 | 说明 | |------|------| | eq(field, value) | 等于 | | ne(field, value) | 不等于 | | gt(field, value) | 大于 | | gte(field, value) | 大于等于 | | lt(field, value) | 小于 | | lte(field, value) | 小于等于 | | contains(field, value) | 模糊包含 (LIKE %value%) | | notContains(field, value) | 不包含 (NOT LIKE %value%) | | startsWith(field, value) | 前缀匹配 | | endsWith(field, value) | 后缀匹配 | | in(field, values) | 在列表中 | | notIn(field, values) | 不在列表中 | | between(field, min, max) | 范围查询 | | isNull(field) | 为空 (IS NULL) | | isNotNull(field) | 不为空 (IS NOT NULL) | | isEmpty(field) | 空字符串 (= '' OR IS NULL) | | isNotEmpty(field) | 非空字符串 (!= '' AND IS NOT NULL) | | keyword(keyword) | 关键词搜索 | | sort(field, order) | 排序 (order: 'asc' / 'desc') | | asc(field) | 升序排序 | | desc(field) | 降序排序 | | page(page, pageSize) | 分页 (默认 pageSize=20) | | or(fn) | 添加 OR 组 | | and(fn) | 添加 AND 组 | | orGroup(fns) | 多个 AND 组之间 OR | | build() | 构建 JsonQuery 对象 |

createEntityApi

const api = createEntityApi<T>(basePath, options?)

| 方法 | HTTP | 说明 | |------|------|------| | query(jsonQuery) | POST .../query | JSON 动态查询 | | list(params?) | GET .../list | 简单列表查询 | | get(id) | GET .../id | 按 ID 获取 | | create(data) | POST ... | 创建 | | update(id, data) | PUT .../id | 更新 | | delete(id) | DELETE .../id | 删除 |

License

MIT