api-pagination by aj-geddes/useful-ai-prompts
npx skills add https://github.com/aj-geddes/useful-ai-prompts --skill api-pagination实现可扩展的分页策略,以高效处理大型数据集,包括高效查询、导航和性能优化。
最小工作示例:
// Node.js offset/limit 实现
app.get('/api/users', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100); // 最大 100
const offset = (page - 1) * limit;
try {
const [users, total] = await Promise.all([
User.find()
.skip(offset)
.limit(limit)
.select('id email firstName lastName createdAt'),
User.countDocuments()
]);
const totalPages = Math.ceil(total / limit);
res.json({
data: users,
pagination: {
page,
limit,
total,
totalPages,
hasNext: page < totalPages,
// ... (完整实现请参阅参考指南)
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
references/ 目录下的详细实现:
| 指南 | 内容 |
|---|---|
| Offset/Limit 分页 | Offset/Limit 分页 |
| 基于游标的分页 | 基于游标的分页 |
| Keyset 分页 | Keyset 分页 |
| 搜索分页 | 搜索分页 |
| 分页响应格式 | 分页响应格式 |
| Python 分页 (SQLAlchemy) | Python 分页 (SQLAlchemy) |
每周安装量
120
代码仓库
GitHub 星标数
126
首次出现
2026年1月21日
安全审计
安装于
gemini-cli102
opencode101
codex97
cursor90
claude-code90
github-copilot85
Implement scalable pagination strategies for handling large datasets with efficient querying, navigation, and performance optimization.
Minimal working example:
// Node.js offset/limit implementation
app.get('/api/users', async (req, res) => {
const page = parseInt(req.query.page) || 1;
const limit = Math.min(parseInt(req.query.limit) || 20, 100); // Max 100
const offset = (page - 1) * limit;
try {
const [users, total] = await Promise.all([
User.find()
.skip(offset)
.limit(limit)
.select('id email firstName lastName createdAt'),
User.countDocuments()
]);
const totalPages = Math.ceil(total / limit);
res.json({
data: users,
pagination: {
page,
limit,
total,
totalPages,
hasNext: page < totalPages,
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Offset/Limit Pagination | Offset/Limit Pagination |
| Cursor-Based Pagination | Cursor-Based Pagination |
| Keyset Pagination | Keyset Pagination |
| Search Pagination | Search Pagination |
| Pagination Response Formats | Pagination Response Formats |
| Python Pagination (SQLAlchemy) | Python Pagination (SQLAlchemy) |
Weekly Installs
120
Repository
GitHub Stars
126
First Seen
Jan 21, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
gemini-cli102
opencode101
codex97
cursor90
claude-code90
github-copilot85
agent-browser 浏览器自动化工具 - Vercel Labs 命令行网页操作与测试
159,700 周安装
Google Ads 账户深度分析与健康度审计工具 - 74项检查,自动生成优化报告
208 周安装
阿里云CDN OpenAPI自动化操作指南 - 域名管理、缓存刷新、HTTPS证书配置
129 周安装
SpriteKit 常见问题诊断指南:物理接触、帧率优化与内存泄漏排查
134 周安装
iOS游戏开发终极指南:SpriteKit、SceneKit、RealityKit架构、性能优化与故障排除
139 周安装
JSON数据处理教程:Python与JavaScript解析、验证与进阶操作指南
133 周安装
Hookify 规则编写指南:创建自定义代码监控与安全提示规则
142 周安装