Skip to content
This repository was archived by the owner on Jun 22, 2021. It is now read-only.

Commit 2c1032a

Browse files
committed
docs(options): Improve docs for options.
1 parent 4829d22 commit 2c1032a

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

docs/options.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,29 +2,50 @@
22

33
The [facade](./facade.md) [functions](./functions.md) have some common options that they use.
44

5-
- [Entity](#entity)
65
- [Id](#id)
6+
- [Entity](#entity)
77
- [Patch](#patch)
88
- [Filter](#filter)
99
- [Sort](#sort)
1010
- [Pagination](#pagination)
1111

12+
### Id
13+
This is an object that contains only the properties required to distinctly identify an entity. In most common cases there is a single property making the [unique key](https://en.wikipedia.org/wiki/Unique_key) so it will likely just contain the `id` property. However, for entities with multiple properties making the unique key it will contain those properties.
14+
15+
This interface is user-defined hence not contained in this package, the interface below demonstrates what this will look like in most cases.
16+
17+
```ts
18+
interface Id {
19+
readonly id: string;
20+
}
21+
```
22+
1223
### Entity
1324
This is an object contains all of the entity's properties. The word "entity" has been borrowed from Entity-Relationship Models/Diagrams and has been used instead of the word "model" to avoid confusion with MVC.
1425

15-
### Id
16-
This is an object that contains only the properties required to distinctly identify an entity. In most common cases there is a single property making the [unique key](https://en.wikipedia.org/wiki/Unique_key) so it will likely just contain the `id` property. However, for entities with multiple properties making the unique key it will contain those properties.
26+
This interface is user-defined hence not contained in this package, the interface below demonstrates what this might look like for a todo entity and extends the [Id interface from the Id example](#id).
27+
28+
```ts
29+
interface TodoEntity extends Id {
30+
readonly description: string;
31+
readonly completed: boolean;
32+
}
33+
```
1734

1835
### Patch
19-
This is an object containing some of the entity's properties.
36+
This is an object containing some of the entity's properties. This package uses [TypeScript's Partial type](https://www.typescriptlang.org/docs/handbook/advanced-types.html) applied to an [Entity](#entity) (using `Partial<Entity>`).
2037

2138
### Filter
2239
This is an object that filters the entities. More information can be found in the [filter documentation](./filter.md).
2340

2441
### Sort
2542
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.
2643

44+
This package contains the [TypeScript Sort type definition](../src/types/Sort.ts)
45+
2746
### Pagination
2847
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 iterate through the entities forwards (when `true`) or backwards (when `false`) from the `cursor`. The `cursor` property defines where to start iterating through the entities.
2948

30-
Concrete implementations of the facade can use the [`createCursorFromEntity`](../src/utils/createCursorFromEntity) and [`createPaginationFilter`](../src/utils/createPaginationFilter) util functions to generate cursors.
49+
Concrete implementations of the facade can use the [`createCursorFromEntity`](../src/utils/createCursorFromEntity) and [`createPaginationFilter`](../src/utils/createPaginationFilter) util functions to generate cursors.
50+
51+
This package also contains the [TypeScript Pagination interface](../src/types/Pagination.ts) and the [TypeScript Cursor type definition](../src/types/Cursor.ts).

0 commit comments

Comments
 (0)