## 问题现象 通过 `GET /api/v1/data/:object` 拉列表时,分页拿不到真实总数,导致前端表格无法翻页。 一张有 **3125** 条记录的表为例: | 请求 | 实际返回 | 期望 | |---|---|---| | 不带 limit | `total: 3125`,返回全部 3125 条 | ✓ | | `?$top=100&$skip=0` | `records: 100`,但 `total: 100` | `total` 应为 3125 | | `?$top=100&$count=true` | `total: 100`(`$count` 被忽略) | `total` 应为 3125 | | 任意请求 | `hasMore` 恒为 `false` | 后面还有数据时应为 `true` | **直接后果:** 前端表格(console / objectui grid)拿不到匹配总数,只能用「本批条数 ÷ 每页行数」当总页数。于是一张 3000+ 行的表显示「共 10 页」,翻到第 11 页就没有数据——**无法翻页到第 101 条之后**。 ## 根因 `packages/objectql/src/protocol.ts` 的 `findData()`: - 入口已解析 `$count`(`protocol.ts:2023` 把 `$count → count`); - 但收尾时没用它,`total` 直接写成本批条数、`hasMore` 写死 `false`: ```ts // protocol.ts:2179-2187 const records = await this.engine.find(request.object, options); return { object: request.object, records, total: records.length, // ← 只是本页条数,不是匹配总数 hasMore: false // ← 恒为 false }; ``` 聚合分支 `protocol.ts:2171-2176` 同样如此。看起来是没写完的占位实现:契约层 `spec/api/contract.zod.ts:84-91` 已定义完整分页字段、引擎 `engine.ts` 已有 `count(object, query)` 方法,唯独 `findData` 没调用。 ## 期望 带 `limit` 时,`findData` 返回真实分页元数据:`total` = 满足 `where` 的匹配总数(复用现成的 `engine.count`),`hasMore` = `offset + records.length < total`;不带 limit 时维持现状。 **环境:** ObjectStack 10.0.0(`@objectstack/objectql@10.0.0`)
Activity
chore(changeset): add patch changeset for findData pagination fix (#2212
fix(objectql): findData 返回真实 total/hasMore (#2212) (#2222)
fix(plugin-grid): the grid's fetch batch follows server grouping, and…
feat(plugin-grid): one display page size read from the spec, and a di…