Skip to content

Commit 87a65ba

Browse files
committed
docs: Remove unneeded id pk from examples
1 parent 9ebc6cd commit 87a65ba

File tree

17 files changed

+62
-176
lines changed

17 files changed

+62
-176
lines changed

.changeset/fast-jars-run.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@data-client/endpoint': patch
3+
'@data-client/rest': patch
4+
'@data-client/graphql': patch
5+
---
6+
7+
Fix Entity types for TS 4.0 and below

docs/core/concepts/normalization.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,13 @@ class Todo extends Entity {
2929
readonly userId: number = 0;
3030
readonly title: string = '';
3131
readonly completed: boolean = false;
32-
33-
pk() {
34-
return `${this.id}`;
35-
}
3632
}
3733
```
3834
3935
```js
4036
import { Entity } from '@data-client/endpoint';
4137
4238
class Todo extends Entity {
43-
pk() {
44-
return `${this.id}`;
45-
}
4639
}
4740
```
4841

docs/core/guides/ssr.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,6 @@ class User extends Entity {
9494
id = '';
9595
username = '';
9696

97-
pk() {
98-
return this.id;
99-
}
100-
10197
// highlight-next-line
10298
static key = 'User';
10399
}

examples/coin-app/src/resources/Currency.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ export class Currency extends Entity {
3636
return iconTable[this.id]?.img_url;
3737
}
3838

39-
pk(): string {
40-
return this.id;
41-
}
42-
4339
static key = 'Currency';
4440

4541
static process(

examples/coin-app/src/resources/Product.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export class Product extends Entity {
1111
trading_disabled = false;
1212
stats = Stats.fromJS();
1313

14-
pk(): string {
15-
return this.id;
16-
}
17-
1814
static key = 'Product';
1915
static schema = {
2016
stats: Stats,

examples/github-app/src/resources/Base.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ const HOST = 'https://api.github.com';
2424

2525
export class GithubEntity extends Entity {
2626
readonly id: number = -1;
27-
28-
pk() {
29-
return this.id?.toString();
30-
}
3127
}
3228

3329
export const GithubGqlEndpoint = new GQLEndpoint(

examples/github-app/src/resources/Label.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ export class Label extends GithubEntity {
77
readonly description: string = '';
88
readonly color: string = '000000';
99
readonly default: boolean = false;
10-
11-
pk() {
12-
return this.id?.toString();
13-
}
1410
}
1511
export const LabelResource = githubResource({
1612
path: '/repos/:owner/:repo/labels/:name',

examples/github-app/src/resources/Push.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class Push extends GithubEntity {
1010
commits: Commit[] = [];
1111

1212
pk() {
13-
return `${this.pushId}`;
13+
return this.pushId;
1414
}
1515
}
1616

examples/github-app/src/resources/Reaction.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@ export class Reaction extends GithubEntity {
1414
return contentToIcon[this.content];
1515
}
1616

17-
pk() {
18-
return this.id?.toString();
19-
}
20-
2117
static schema = {
2218
user: User,
2319
createdAt: Temporal.Instant.from,

examples/nextjs/resources/PlaceholderBaseResource.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@ import {
77
} from '@data-client/rest';
88

99
export abstract class PlaceholderEntity extends Entity {
10-
id = 0;
11-
1210
// all Resources of `jsonplaceholder` use an id for the primary key
13-
pk() {
14-
return `${this.id}`;
15-
}
11+
id = 0;
1612
}
1713

1814
/** Common patterns in the https://jsonplaceholder.typicode.com API */

0 commit comments

Comments
 (0)