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.
Copy file name to clipboardExpand all lines: docs/functions.md
+7-7
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Creates a new entity using the `entity` option if no entity exists that matches
28
28
29
29
```ts
30
30
const { entity } =awaitfacade.createEntity({
31
-
id: { id: 'example_id' },
31
+
id: 'example_id',
32
32
entity: { id: 'example_id', foo: 'bar' },
33
33
});
34
34
```
@@ -63,7 +63,7 @@ Retrieves a single entity that matches the `id` option.
63
63
64
64
```ts
65
65
const { entity } =awaitfacade.getEntity({
66
-
id: { id: 'example_id' },
66
+
id: 'example_id',
67
67
});
68
68
```
69
69
@@ -74,7 +74,7 @@ For an entity that matches the `id` option, it changes all of an entity's proper
74
74
75
75
```ts
76
76
const { entity } =awaitfacade.overwriteEntity({
77
-
id: { id: 'example_id' },
77
+
id: 'example_id',
78
78
entity: { id: 'example_id', foo: 'bar' },
79
79
});
80
80
```
@@ -86,7 +86,7 @@ For an entity that matches the `id` option, it changes some of an entity's prope
86
86
87
87
```ts
88
88
const { entity } =awaitfacade.patchEntity({
89
-
id: { id: 'example_id' },
89
+
id: 'example_id',
90
90
patch: { foo: 'bar' },
91
91
});
92
92
```
@@ -109,7 +109,7 @@ Removes an entity that matches the `id` option.
109
109
110
110
```ts
111
111
awaitfacade.removeEntity({
112
-
id: { id: 'example_id' },
112
+
id: 'example_id',
113
113
});
114
114
```
115
115
@@ -120,9 +120,9 @@ Creates an entity when no entity exists that matches the `id` option. Otherwise,
120
120
121
121
```ts
122
122
awaitfacade.upsertEntity({
123
-
id: { id: 'example_id' },
123
+
id: 'example_id',
124
124
entity: { id: 'example_id', foo: 'bar' },
125
125
});
126
126
```
127
127
128
-
This package contains the [upsert entity tests](../src/tests/upsertsEntity) and the [upsert entity signature](../src/signatures/UpsertEntity.ts) for this function.
128
+
This package contains the [upsert entity tests](../src/tests/upsertsEntity) and the [upsert entity signature](../src/signatures/UpsertEntity.ts) for this function.
Copy file name to clipboardExpand all lines: docs/options.md
+7-13
Original file line number
Diff line number
Diff line change
@@ -10,23 +10,17 @@ The [facade](./facade.md) [functions](./functions.md) have some common options t
10
10
-[Pagination](#pagination)
11
11
12
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
-
interfaceId {
19
-
readonly id:string;
20
-
}
21
-
```
13
+
This is a string that uniquely identifies an entity.
22
14
23
15
### Entity
24
16
This is an object that contains all of the entity's properties. The word "entity" has been borrowed from [Entity-Relationship Models/Diagrams](https://en.wikipedia.org/wiki/Entity%E2%80%93relationship_model) and has been used instead of the word "model" to avoid confusion with MVC.
25
17
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).
18
+
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 [TypeScript Entity interface](../src/types/Entity.ts) defined in this package which contains the `id` property.
@@ -44,8 +38,8 @@ This is an object where a key represents the entity property to be sorted and th
44
38
This package contains the [TypeScript Sort type definition](../src/types/Sort.ts).
45
39
46
40
### Pagination
47
-
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.
41
+
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/).
48
42
49
-
Concrete implementations of the facade can use the [`createCursorFromEntity`](../src/utils/createCursorFromEntity) and [`createPaginationFilter`](../src/utils/createPaginationFilter)util functions to generate cursors.
43
+
Concrete implementations of the facade can use the [`createCursorFromEntity`](../src/utils/createCursorFromEntity) and [`createPaginationFilter`](../src/utils/createPaginationFilter)utility functions to generate cursors.
50
44
51
45
This package also contains the [TypeScript Pagination interface](../src/types/Pagination.ts) and the [TypeScript Cursor type definition](../src/types/Cursor.ts).
Copy file name to clipboardExpand all lines: readme.md
+10
Original file line number
Diff line number
Diff line change
@@ -4,3 +4,13 @@
4
4
### Usage
5
5
- Install it with `npm i @js-entity-repos/core`.
6
6
- Understand it by reading the [documenation](./docs/facade.md).
7
+
8
+
### FeathersJS
9
+
The project has some similarities with parts of the [FeathersJS framework](feathersjs.com), but unfortunately I've found the following issues with FeathersJS.
10
+
11
+
- Their pagination uses skip and limit instead of cursors which causes [issues as discussed by Rakhitha Nimesh](https://www.sitepoint.com/paginating-real-time-data-cursor-based-pagination/).
12
+
- Their service interface is missing some functions provided in the [Facade](./docs/facade.md) here.
13
+
- Their errors take messages instead of parameters making it harder to support localisation.
14
+
15
+
### Thanks
16
+
Thanks to [James](https://github.com/ht2), [Mariusz](https://github.com/mariocoski), and [Pete](https://github.com/ee0pdt) at [HT2 Labs](https://www.ht2labs.com) for their feedback.
0 commit comments