Repository navigation
v1.2.0 Release Notes
This release introduces powerful enhancements to the read and readWith methods by adding support for:
- Sorting (
orderBy,direction) - Pagination (
limit,offset)
These features allow you to build cleaner APIs, faster admin tools, and scalable data listings with minimal effort.
New Features
1. Sorting Support
You can now sort results using orderBy and direction.
Usage:
await read('users', {}, {
orderBy: 'created_at',
direction: 'DESC'
});
2. Pagination Support
Limit the number of returned records and skip records using limit and offset.
Usage:
await read('posts', {}, {
orderBy: 'created_at',
direction: 'ASC',
limit: 10,
offset: 20 // Page 3, assuming 10 per page
});
3. readWith() Enhanced
The readWith method now also supports sorting and pagination across joined tables.
Usage:
await readWith('orders', {}, [
{ table: 'users', on: ['orders.user_id', 'users.id'], type: 'left' }
], {
orderBy: 'orders.created_at',
direction: 'DESC',
limit: 5,
offset: 10
});
Test Coverage
- Bulk record inserts added for pagination simulation
- New tests for:
read()withorderByandlimit/offsetreadWith()with joins and pagination
- Validated sorting direction and dataset correctness
Migration Notes
No breaking changes. Existing read() and readWith() calls will continue to work as before.
These new options are fully backward-compatible and optional.
What’s Next
- Optional field selection (
select) - Pagination metadata (
total,pages) - Default sort support in struct definitions
Thank you for using ts-orm. Feedback and contributions welcome.