重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
api-filtering-sorting by secondsky/claude-skills
npx skills add https://github.com/secondsky/claude-skills --skill api-filtering-sorting构建灵活的过滤和排序系统,高效处理复杂查询。
GET /products?category=electronics&price[gte]=100&price[lte]=500&sort=-price,name
const allowedFilters = ['category', 'status', 'price', 'createdAt'];
const allowedSorts = ['name', 'price', 'createdAt'];
app.get('/products', async (req, res) => {
const filter = {};
const sort = {};
// 解析过滤器
for (const [key, value] of Object.entries(req.query)) {
if (key === 'sort') continue;
const match = key.match(/^(\w+)\[(\w+)\]$/);
if (match) {
const [, field, operator] = match;
if (!allowedFilters.includes(field)) continue;
filter[field] = { [`$${operator}`]: parseValue(value) };
} else if (allowedFilters.includes(key)) {
filter[key] = value;
}
}
// 解析排序
if (req.query.sort) {
for (const field of req.query.sort.split(',')) {
const direction = field.startsWith('-') ? -1 : 1;
const name = field.replace(/^-/, '');
if (allowedSorts.includes(name)) sort[name] = direction;
}
}
const products = await Product.find(filter).sort(sort);
res.json({ data: products });
});
function parseValue(value) {
if (value === 'true') return true;
if (value === 'false') return false;
if (!isNaN(value)) return Number(value);
return value;
}
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 运算符 | 含义 | 示例 |
|---|---|---|
| eq | 等于 | ?status=active |
| ne | 不等于 | ?status[ne]=deleted |
| gt/gte | 大于 | ?price[gte]=100 |
| lt/lte | 小于 | ?price[lte]=500 |
| in | 在数组中 | ?status[in]=active,pending |
| like | 包含 | ?name[like]=phone |
每周安装量
65
代码仓库
GitHub 星标数
90
首次出现
2026年1月22日
安全审计
安装于
claude-code57
gemini-cli52
codex51
opencode50
cursor50
github-copilot47
Build flexible filtering and sorting systems that handle complex queries efficiently.
GET /products?category=electronics&price[gte]=100&price[lte]=500&sort=-price,name
const allowedFilters = ['category', 'status', 'price', 'createdAt'];
const allowedSorts = ['name', 'price', 'createdAt'];
app.get('/products', async (req, res) => {
const filter = {};
const sort = {};
// Parse filters
for (const [key, value] of Object.entries(req.query)) {
if (key === 'sort') continue;
const match = key.match(/^(\w+)\[(\w+)\]$/);
if (match) {
const [, field, operator] = match;
if (!allowedFilters.includes(field)) continue;
filter[field] = { [`$${operator}`]: parseValue(value) };
} else if (allowedFilters.includes(key)) {
filter[key] = value;
}
}
// Parse sort
if (req.query.sort) {
for (const field of req.query.sort.split(',')) {
const direction = field.startsWith('-') ? -1 : 1;
const name = field.replace(/^-/, '');
if (allowedSorts.includes(name)) sort[name] = direction;
}
}
const products = await Product.find(filter).sort(sort);
res.json({ data: products });
});
function parseValue(value) {
if (value === 'true') return true;
if (value === 'false') return false;
if (!isNaN(value)) return Number(value);
return value;
}
| Operator | Meaning | Example |
|---|---|---|
| eq | Equals | ?status=active |
| ne | Not equals | ?status[ne]=deleted |
| gt/gte | Greater than | ?price[gte]=100 |
| lt/lte | Less than | ?price[lte]=500 |
| in | In array | ?status[in]=active,pending |
Weekly Installs
65
Repository
GitHub Stars
90
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketWarnSnykPass
Installed on
claude-code57
gemini-cli52
codex51
opencode50
cursor50
github-copilot47
lark-cli 共享规则:飞书资源操作指南与权限配置详解
41,800 周安装
| like | Contains | ?name[like]=phone |