Skip to content

Commit dda505f

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

File tree

15 files changed

+19
-90
lines changed

15 files changed

+19
-90
lines changed

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 */

examples/normalizr-github/schema.js

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
import { schema, Entity } from '@data-client/endpoint';
22

3-
class BaseEntity extends Entity {
4-
id = 0;
3+
export class User extends Entity {}
54

6-
pk() {
7-
return this.id;
8-
}
9-
}
10-
11-
export class User extends BaseEntity {}
12-
13-
export class Commit extends BaseEntity {
5+
export class Commit extends Entity {
146
sha = '';
157

168
static schema = {
@@ -23,15 +15,15 @@ export class Commit extends BaseEntity {
2315
}
2416
}
2517

26-
export class Label extends BaseEntity {}
18+
export class Label extends Entity {}
2719

28-
export class Milestone extends BaseEntity {
20+
export class Milestone extends Entity {
2921
static schema = {
3022
creator: User,
3123
};
3224
}
3325

34-
export class Issue extends BaseEntity {
26+
export class Issue extends Entity {
3527
static schema = {
3628
assignee: User,
3729
assignees: [User],
@@ -41,7 +33,7 @@ export class Issue extends BaseEntity {
4133
};
4234
}
4335

44-
export class PullRequest extends BaseEntity {
36+
export class PullRequest extends Entity {
4537
static schema = {
4638
assignee: User,
4739
assignees: [User],

0 commit comments

Comments
 (0)