我使用json-server ,我使用这样的数据:
{
"posts": [
{ "id": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "id": 1, "body": "some comment", "postId": 1 }
]
}
我想使用uuid而不是id,如下所示:
{
"posts": [
{ "uuid": 1, "title": "json-server", "author": "typicode" }
],
"comments": [
{ "uuid": 1, "body": "some comment", "postId": 1 }
]
}
但问题是 json-server 在搜索时使用 id 作为主键,例如:
endpoint/posts/1
- 有id它的工作
- 使用uuid不起作用
有没有办法让 json-server 依赖uuid而不是id