Skip to content

Commit 89d985e

Browse files
authored
Merge pull request #32 from mnfst/uuid
docs: replace int ids by uuids
2 parents 4d8c7ae + 948bc3b commit 89d985e

File tree

7 files changed

+47
-45
lines changed

7 files changed

+47
-45
lines changed

angular.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ import Manifest from '@mnfst/sdk'
4646
styleUrls: ['./app.component.css']
4747
})
4848
export class AppComponent {
49-
cats: { id: number, name: string }[] = []
49+
cats: { id: string, name: string }[] = []
5050

5151
async ngOnInit() {
5252
// Init SDK.

auth.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ Get the current logged-in user.
161161

162162
```json title="Example HTTP Response"
163163
{
164-
id: 1,
164+
id: 'a8f5f167-6d3b-4c8f-9e2a-7b4d8c9f1e3a',
165165
email: 'contributor@test.com'
166166
}
167167
```

crud.md

Lines changed: 41 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,11 @@ GET /api/collection/users
8282
{
8383
"data": [
8484
{
85-
"id": 1,
85+
"id": "2c4e6a8b-0d1f-4357-9ace-bdf024681357",
8686
"name": "Lara"
8787
},
8888
{
89-
"id": 2,
89+
"id": "e4d5c6b7-a890-4123-9876-543210fedcba",
9090
"name": "Karl"
9191
}
9292
],
@@ -142,11 +142,11 @@ Order your list by a defined property. By default the results are ordered by `id
142142
// Output: {
143143
// "data": [
144144
// {
145-
// "id": 1,
145+
// "id": 'e4d5c6b7-a890-4123-9876-543210fedcba',
146146
// "name": "Lara"
147147
// },
148148
// {
149-
// "id": 2,
149+
// "id": '2c4e6a8b-0d1f-4357-9ace-bdf024681357',
150150
// "name": "Karl"
151151
// }
152152
// ],
@@ -214,7 +214,7 @@ This operation will fetch a single item based on its ID.
214214
**Request URL**: `GET /api/collections/:slug/:id`
215215

216216
```http title="Example HTTP Request"
217-
GET /api/collections/cats/34
217+
GET /api/collections/cats/2c4e6a8b-0d1f-4357-9ace-bdf024681357
218218
```
219219

220220
```json title="Example HTTP Response"
@@ -227,8 +227,8 @@ This operation will fetch a single item based on its ID.
227227
</TabItem>
228228
<TabItem value="sdk" label="JS SDK" default>
229229
```js title="Example SDK usage"
230-
// Get cat with ID 34
231-
const cat = await manifest.from('cats').findOneById(34)
230+
// Get cat with ID 2c4e6a8b-0d1f-4357-9ace-bdf024681357
231+
const cat = await manifest.from('cats').findOneById('2c4e6a8b-0d1f-4357-9ace-bdf024681357')
232232

233233
console.log(cat);
234234
// Output: {
@@ -261,7 +261,7 @@ This operation will create a new item and store it in the database. The newly cr
261261

262262
```json title="Example HTTP Response"
263263
{
264-
"id": 25,
264+
"id": '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
265265
"name": "Pikachu",
266266
"type": "electric",
267267
"level": 3,
@@ -280,7 +280,7 @@ This operation will create a new item and store it in the database. The newly cr
280280

281281
console.log(newPokemon);
282282
// Output: {
283-
// id: 25,
283+
// id: '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
284284
// name: "Pikachu",
285285
// type: "electric",
286286
// level: 3
@@ -301,7 +301,7 @@ Unlike [partial updates](#patch-an-item), this operation will replace the whole
301301
**Request URL**: `PUT /api/collections/:slug/:id`
302302

303303
```http title="Example HTTP Request"
304-
PUT /api/collections/pokemons/25
304+
PUT /api/collections/pokemons/6ba7b810-9dad-11d1-80b4-00c04fd430c8
305305
Content-Type: application/json
306306
Body:
307307
{
@@ -314,7 +314,7 @@ Unlike [partial updates](#patch-an-item), this operation will replace the whole
314314

315315
```json title="Example HTTP Response"
316316
{
317-
"id": 25,
317+
"id": '6ba7b810-9dad-11d1-80b4-00c04fd430c8',
318318
"name": "Raichu",
319319
"type": "electric",
320320
"level": 8
@@ -324,16 +324,16 @@ Unlike [partial updates](#patch-an-item), this operation will replace the whole
324324
</TabItem>
325325
<TabItem value="sdk" label="JS SDK" default>
326326
```js title="Example SDK usage"
327-
// Updates the Pokemon item with ID 25.
328-
const newPokemon = await manifest.from('pokemons').update(25, {
327+
// Updates the Pokemon item with ID a1b2c3d4-e5f6-4789-abcd-ef0123456789.
328+
const newPokemon = await manifest.from('pokemons').update('a1b2c3d4-e5f6-4789-abcd-ef0123456789', {
329329
name: "Raichu",
330330
type: "electric",
331331
level: 8,
332332
})
333333

334334
console.log(newPokemon);
335335
// Output: {
336-
// id: 25,
336+
// id: 'a1b2c3d4-e5f6-4789-abcd-ef0123456789',
337337
// name: "Raichu",
338338
// type: "electric",
339339
// level: 8
@@ -353,7 +353,7 @@ Unlike [fully replacement](#update-an-item), this operation will only modify the
353353
**Request URL**: `PATCH /api/collections/:slug/:id`
354354

355355
```http title="Example HTTP Request"
356-
PATCH /api/collections/pokemons/25
356+
PATCH /api/collections/pokemons/a1b2c3d4-e5f6-4789-abcd-ef0123456789
357357
Content-Type: application/json
358358
Body:
359359
{
@@ -363,7 +363,7 @@ Unlike [fully replacement](#update-an-item), this operation will only modify the
363363

364364
```json title="Example HTTP Response"
365365
{
366-
"id": 25,
366+
"id": 'a1b2c3d4-e5f6-4789-abcd-ef0123456789',
367367
"name": "Pikachu",
368368
"type": "electric",
369369
"level": 5
@@ -373,14 +373,14 @@ Unlike [fully replacement](#update-an-item), this operation will only modify the
373373
</TabItem>
374374
<TabItem value="sdk" label="JS SDK" default>
375375
```js title="Example SDK usage"
376-
// Patches the Pokemon item with ID 25.
377-
const newPokemon = await manifest.from('pokemons').patch(25, {
376+
// Patches the Pokemon item with ID a1b2c3d4-e5f6-4789-abcd-ef0123456789.
377+
const newPokemon = await manifest.from('pokemons').patch('a1b2c3d4-e5f6-4789-abcd-ef0123456789', {
378378
level: 5
379379
})
380380

381381
console.log(newPokemon);
382382
// Output: {
383-
// id: 25,
383+
// id: 'a1b2c3d4-e5f6-4789-abcd-ef0123456789',
384384
// name: "Pikachu",
385385
// type: "electric",
386386
// level: 5
@@ -399,7 +399,8 @@ This operation will delete permanently an item from the database. This is an irr
399399
**Request URL**: `DELETE /api/collections/:slug/:id`
400400

401401
```http title="Example HTTP Request"
402-
DELETE api/collections/cats/60
402+
DELETE api/collections/cats/550e8400-e29b-41d4-a716-446655440000
403+
403404
```
404405

405406
```json title="Example HTTP Response"
@@ -412,8 +413,9 @@ DELETE api/collections/cats/60
412413
</TabItem>
413414
<TabItem value="sdk" label="JS SDK" default>
414415
```js title="Example SDK usage"
415-
// Delete the cat with ID 60.
416-
const deletedCat = await manifest.from('cats').delete(60)
416+
// Delete the cat with ID 550e8400-e29b-41d4-a716-446655440000
417+
.
418+
const deletedCat = await manifest.from('cats').delete('550e8400-e29b-41d4-a716-446655440000')
417419

418420
console.log(deletedCat);
419421
// Output: {
@@ -593,11 +595,11 @@ Once the relation is loaded, you can also filter items by their relation id or p
593595
<Tabs>
594596
<TabItem value="sdk" label="JS SDK" default>
595597
```js
596-
// Get all cats that belong to owner with id 1.
598+
// Get all cats that belong to owner with id 3f2504e0-4f89-11d3-9a0c-0305e82c3301.
597599
const cats = await manifest
598600
.from('cats')
599601
.with(['owner'])
600-
.where('owner.id = 1')
602+
.where('owner.id = 3f2504e0-4f89-11d3-9a0c-0305e82c3301')
601603
.find()
602604
603605
// Get all cats that have an owner with name "Jorge".
@@ -611,8 +613,8 @@ Once the relation is loaded, you can also filter items by their relation id or p
611613
</TabItem>
612614
<TabItem value="rest" label="REST API" default>
613615
```http
614-
// Get all cats that belong to owner with id 1.
615-
GET http://localhost:1111/api/dynamic/cats?relations=owner&owner.id_eq=1
616+
// Get all cats that belong to owner with id 3f2504e0-4f89-11d3-9a0c-0305e82c3301.
617+
GET http://localhost:1111/api/dynamic/cats?relations=owner&owner.id_eq=3f2504e0-4f89-11d3-9a0c-0305e82c3301
616618
617619
// Get all cats that have an owner with name "Jorge".
618620
GET http://localhost:1111/api/dynamic/cats?relations=owner&owner.name_eq=Jorge
@@ -634,8 +636,8 @@ To store or update an item with its relations, you have to pass the relation id(
634636
Content-Type: application/json
635637
{
636638
"name": "Mike",
637-
"teamId": 10,
638-
"skillIds": [1,2,3,4,5]
639+
"teamId": 'e4d5c6b7-a890-4123-9876-543210fedcba',
640+
"skillIds": ['12345678-1234-5678-9abc-123456789012', '3f2504e0-4f89-11d3-9a0c-0305e82c3301']
639641
}
640642
```
641643

@@ -645,8 +647,8 @@ To store or update an item with its relations, you have to pass the relation id(
645647
// Store a new player with relations Team and Skill.
646648
const newPlayer = await manifest.from('players').create({
647649
name: 'Mike',
648-
teamId: 10,
649-
skillIds: [1,2,3,4,5]
650+
teamId: 'e4d5c6b7-a890-4123-9876-543210fedcba',
651+
skillIds: ['12345678-1234-5678-9abc-123456789012', '3f2504e0-4f89-11d3-9a0c-0305e82c3301']
650652
})
651653
```
652654

@@ -667,34 +669,34 @@ As for updating properties, you can either do a **full replacement** using the u
667669
<TabItem value="rest" label="REST API" default>
668670
```http
669671
// Replaces the whole skill relations by the new skillIds array.
670-
PUT http://localhost:1111/api/dynamic/players/1
672+
PUT http://localhost:1111/api/dynamic/players/e4d5c6b7-a890-4123-9876-543210fedcba
671673
Content-Type: application/json
672674
{
673675
name: 'Mike',
674-
teamId: 10,
675-
skillIds: [10, 11]
676+
teamId: 'e4d5c6b7-a890-4123-9876-543210fedcba',
677+
skillIds: ['12345678-1234-5678-9abc-123456789012', '3f2504e0-4f89-11d3-9a0c-0305e82c3301']
676678
}
677679

678680
// Updates the team without changing the skills or the name.
679-
PATCH http://localhost:1111/api/dynamic/players/1
681+
PATCH http://localhost:1111/api/dynamic/players/e4d5c6b7-a890-4123-9876-543210fedcba
680682
Content-Type: application/json
681683
{
682-
teamId: 5,
684+
teamId: '9b2fff23-ec93-4b48-9322-bbd4b6b5b123',
683685
}
684686
```
685687

686688
</TabItem>
687689
<TabItem value="sdk" label="JS SDK" default>
688690
```js
689691
// Replaces the whole skill relations by the new skillIds array.
690-
await manifest.from('players').update(1, {
692+
await manifest.from('players').update('e4d5c6b7-a890-4123-9876-543210fedcba', {
691693
name: 'Mike',
692-
teamId: 10,
693-
skillIds: [10, 11]
694+
teamId: 'e4d5c6b7-a890-4123-9876-543210fedcba',
695+
skillIds: ['12345678-1234-5678-9abc-123456789012', '3f2504e0-4f89-11d3-9a0c-0305e82c3301']
694696
})
695697
696698
// Updates the team without changing the skills or the name.
697-
await manifest.from('players').patch(1, {teamId: 5})
699+
await manifest.from('players').patch('e4d5c6b7-a890-4123-9876-543210fedcba', {teamId: '9b2fff23-ec93-4b48-9322-bbd4b6b5b123'})
698700
```
699701

700702
</TabItem>

entities.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ entities:
3232
- name
3333
```
3434
35-
This file will generate the **Cat** and **Dog** entity both with a `name` property. In Manifest by default all entities have an incremental **id** so you do not need to add it. They also have automatic **createdAt** and **updatedAt** columns that are not selected by default in the API requests.
35+
This file will generate the **Cat** and **Dog** entity both with a `name` property. In Manifest by default all entities have an **id** (UUID format) so you do not need to add it. They also have automatic **createdAt** and **updatedAt** columns that are not selected by default in the API requests.
3636

3737
You can now add your own pets through the admin panel!
3838

react.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { useEffect, useState } from "react";
4242

4343
function App() {
4444
interface Cat {
45-
id: number;
45+
id: string;
4646
name: string;
4747
}
4848

svelte.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ In that example we are using a Cat entity [created previously](entities.md). Rep
4545
import { onMount } from "svelte";
4646

4747
interface Cat {
48-
id: number;
48+
id: string;
4949
name: string;
5050
type: string;
5151
image: string;

vue.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ In that example we are using a Cat entity [created previously](entities.md). Rep
4242
import Manifest from "@mnfst/sdk";
4343

4444
interface Cat {
45-
id: number;
45+
id: string;
4646
name: string;
4747
type: string;
4848
image: string;

0 commit comments

Comments
 (0)