Repository navigation
Pagination and standardized results for all() and find()
This release adds pagination and standardizes the return shapes for query operations to make results predictable and to expose useful metadata for clients.
New Features
- Pagination for all() (src/ops/all.ts) [bfb1f27]:
- all() now returns AllOperationResult instead of an array, including metadata: { total, returned, limit, offset, hasMore }.
- Supports optional AllOptions with limit and offset. Effective limit/offset are determined with allOptions taking precedence over values in the query.
- total is computed before pagination is applied.
Improvements
- Standardized results for find() (src/Operations.ts) [bfb1f27]:
- operations.find() now accepts an optional findOptions parameter and returns Promise<FindOperationResult>.
- If a finder still returns a V[] (legacy), the library wraps it into FindOperationResult with items and metadata.
- Finders can now receive (params, locations, findOptions) to opt into pagination.
- Consistent one-item retrieval (src/ops/one.ts, src/Operations.ts) [bfb1f27]:
- operations.findOne() invokes the finder with { limit: 1 } and correctly handles both FindOperationResult and legacy array return types.
- ops/one.ts calls all() using allOptions { limit: 1 } and returns the first item from result.items.
Breaking Changes
- operations.all() return type change [bfb1f27]:
- Before: Promise<V[]>
- Now: Promise<AllOperationResult>
- Update call sites to use result.items and read pagination metadata as needed.
- operations.find() return type change [bfb1f27]:
- Before: Promise<V[]>
- Now: Promise<FindOperationResult>
- If your code expected an array, switch to result.items and use result.metadata when needed.
Developer Notes
- allOptions precedence [bfb1f27]: When both query and allOptions specify limit/offset, allOptions takes precedence.
- Finder compatibility [bfb1f27]: Existing finders that return arrays continue to work. The library wraps arrays into FindOperationResult to provide metadata.
Testing Updates
- Tests updated to consume new result shapes and metadata [bfb1f27]:
- tests/operations/*.test.ts, tests/edge-cases/large-datasets.test.ts now assert result.items and metadata.total.
- tests/e2e/blog-scenario.test.ts and tests/integration/finders-actions-facets.test.ts updated so custom finders use result.items and expect FindOperationResult from operations.find().
Dependency Updates
- Bumped dependencies in package.json [19210e0]:
- @fjell/core ^4.4.63 -> ^4.4.65
- @fjell/lib ^4.4.72 -> ^4.4.74
- @fjell/logging ^4.4.58 -> ^4.4.59
- @fjell/registry ^4.4.69 -> ^4.4.71
- devDependency: @fjell/common-config ^1.1.30 -> ^1.1.31
Version
- Package version bumped to 4.4.25 [5d38550].