api-pagination
仓库创建 2025年11月8日最近提交 29 天前SkillHot 收录 22 天前
▸ 精选理由
帮助开发者根据场景选择最优分页方案,显著提升大表查询性能。
这个 Skill 做什么
提供 offset、cursor 与 keyset 等可扩展分页策略与实现参考。
提供实用的分页策略和实现参考,比较 offset、cursor、keyset 在性能和场景上的差别,并给出落地 API 例子。适合做带分页的接口、实现无限滚动或优化大数据集合的查询。特别强调各策略的性能权衡(如 keyset/cursor 对大数据的 O(1) 优势),方便按场景选最合适的方案。
▸ 展开 SKILL.md 英文原文
Implements efficient API pagination using offset, cursor, and keyset strategies for large datasets. Use when building paginated endpoints, implementing infinite scroll, or optimizing database queries for collections.
180
Stars
28
Forks
40
仓库内 Skill
+0
7 日增星
安装 / 使用
给你的 Agent 一句话(通用)
帮我安装这个 skill:https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/api-pagination/skills/api-pagination/SKILL.md或 curl 直取 SKILL.md
curl -fsSL "https://raw.githubusercontent.com/secondsky/claude-skills/main/plugins/api-pagination/skills/api-pagination/SKILL.md"SKILL.MD 节选查看完整文件 ↗
# API Pagination
Implement scalable pagination strategies for handling large datasets efficiently.
## Pagination Strategies
| Strategy | Best For | Performance |
|----------|----------|-------------|
| Offset/Limit | Small datasets, simple UI | O(n) |
| Cursor | Infinite scroll, real-time | O(1) |
| Keyset | Large datasets | O(1) |
## Offset Pagination
```javascript
app.get('/products', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100);
const offset = (page - 1) * limit;
const [products, total] = await Promise.all([
Product.find().skip(offset).limit(limit),
Product.countDocuments()
]);
resvia SKILL·HOT · 数据来自 GitHub 公开信息 · 原文版权归作者所有