You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 22, 2021. It is now read-only.
refactor: Changes pagination and sorting constants to improve readability. (#8)
BREAKING CHANGE: In pagination `forward` was renamed to `direction`.
BREAKING CHANGE: To paginate forward use `'forward'` in `pagination.direction` instead of `true` in `pagination.forward`. Use `import { forward } from '@js-entity-repos/core/dist/types/PaginationDirection'`.
BREAKING CHANGE: To paginate backward use `'backward'` in `pagination.direction` instead of `false` in `pagination.forward`. Use `import { backward } from '@js-entity-repos/core/dist/types/PaginationDirection'`.
BREAKING CHANGE: To sort in ascending order use `'asc'` in `sort` instead of `true`. Use `import { asc } from '@js-entity-repos/core/dist/types/SortOrder'`.
BREAKING CHANGE: To sort in descending order use `'desc'` in `sort` instead of `false`. Use `import { desc } from '@js-entity-repos/core/dist/types/SortOrder'`.
Copy file name to clipboardExpand all lines: docs/options.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -101,13 +101,13 @@ The filter below is comprehensive example using all of the operators.
101
101
102
102
103
103
### Sort
104
-
This is an object where a key represents the entity property to be sorted and the value represents the direction to sort. The value should be `true` to sort in ascending order and `false` to sort in descending order. The properties are sorted in order of their definition in the sort option, for example, the following sort option `{ createdAt: false, id: true }` will sort by the `createdAt` property first and then the the `id` property.
104
+
This is an object where a key represents the entity property to be sorted and the value represents the direction to sort. The value should be `'asc'` to sort in ascending order and `'desc'` to sort in descending order. The properties are sorted in order of their definition in the sort option, for example, the following sort option `{ createdAt: false, id: true }` will sort by the `createdAt` property first and then the the `id` property.
105
105
106
-
This package contains the [TypeScript Sort type definition](../src/types/Sort.ts).
106
+
This package contains the [TypeScript Sort type definition](../src/types/Sort.ts). It also contains [constants for `'asc'` and `'desc'`](../src/types/SortOrder.ts) that should always be used to avoid breaking changes in the future.
107
107
108
108
### Pagination
109
-
This is an object with three properties, `limit`, `forward`, and `cursor`. The `limit` property defines how many entities to return (maximum). The `forward` property defines whether the entities should be iterated through forwards (when `true`) or backwards (when `false`) from the `cursor`. The `cursor` property defines where to start iterating through the entities. Cursors have been used instead of `skip` and `limit` to avoid the [pagination issues discussed by Rakhitha Nimesh](https://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/).
109
+
This is an object with three properties, `limit`, `direction`, and `cursor`. The `limit` property defines how many entities to return (maximum). The `direction` property defines whether the entities should be iterated through forwards (when `'forward'`) or backwards (when `'backward'`) from the `cursor`. The `cursor` property defines where to start iterating through the entities. Cursors have been used instead of `skip` and `limit` to avoid the [pagination issues discussed by Rakhitha Nimesh](https://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/).
110
110
111
111
Concrete implementations of the facade can use the [`createCursorFromEntity`](../src/utils/createCursorFromEntity) and [`createPaginationFilter`](../src/utils/createPaginationFilter) utility functions to generate cursors.
112
112
113
-
This package also contains the [TypeScript Pagination interface](../src/types/Pagination.ts) and the [TypeScript Cursor type definition](../src/types/Cursor.ts).
113
+
This package contains the [TypeScript Pagination interface](../src/types/Pagination.ts) and the [TypeScript Cursor type definition](../src/types/Cursor.ts). It also contains [constants for `'forward'` and `'backward'`](../src/types/PaginationDirection.ts) that should always be used to avoid breaking changes in the future.
0 commit comments