Skip to content

Commit

Permalink
docs: Add mixing col with row code layouts for EndpointPlayground
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Jan 17, 2024
1 parent ad17239 commit e1f319d
Show file tree
Hide file tree
Showing 5 changed files with 249 additions and 114 deletions.
60 changes: 41 additions & 19 deletions docs/rest/api/createResource.md
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,7 @@ class MyCollection<
}
const TodoResource = createResource({
path: '/todos/:id',
searchParams: {} as
| { userId?: string; orderBy?: string }
| undefined,
searchParams: {} as { userId?: string; orderBy?: string } | undefined,
schema: Todo,
// highlight-next-line
Collection: MyCollection,
Expand Down Expand Up @@ -198,14 +196,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.get({
group: 'react',
id: '1',
Expand Down Expand Up @@ -240,14 +241,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.getList({
group: 'react',
author: 'clara',
Expand Down Expand Up @@ -291,14 +295,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.getList.push(
{ group: 'react', author: 'clara' },
{ title: 'winning' },
Expand Down Expand Up @@ -335,14 +342,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.getList.unshift(
{ group: 'react', author: 'clara' },
{ title: 'winning' },
Expand Down Expand Up @@ -381,15 +391,18 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {9-13}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
paginationField: 'page',
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.getList.getPage({
group: 'react',
author: 'clara',
Expand Down Expand Up @@ -429,14 +442,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.update(
{ group: 'react', id: '1' },
{ title: 'updated title', author: 'clara' },
Expand Down Expand Up @@ -472,14 +488,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.partialUpdate(
{ group: 'react', id: '1' },
{ title: 'updated title' },
Expand Down Expand Up @@ -515,14 +534,17 @@ export default class Post extends Entity {
}
```

```typescript title="Resource" {8-11}
```typescript title="Resource"
import Post from './Post';
const PostResource = createResource({
export const PostResource = createResource({
schema: Post,
path: '/:group/posts/:id',
searchParams: {} as { author?: string },
});
```

```typescript title="Request" column
import { PostResource } from './Resource';
PostResource.delete({ group: 'react', id: '1' });
```

Expand Down
Loading

0 comments on commit e1f319d

Please sign in to comment.