Reputation: 1277
i use json-server and i use data like this:
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
]
}
i want use uuid instead of id, like this:
{
"posts": [
{ "uuid": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "uuid": 1, "body": "some comment", "postId": 1 }
]
}
but the problem is json-server use id as a primary key when you searching , for example:
endpoint/posts/1
Is there a solution to make json-server depend on uuid instead of id
Upvotes: 2
Views: 2949
Reputation: 4836
use --id resource_id where resource is the name of the resource. in your case:
json-server db.json --id 'uuid'
Upvotes: 2