You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/reference/server-adapters/api-handlers/rest.mdx
+15Lines changed: 15 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,6 +99,21 @@ The factory function accepts an options object with the following fields:
99
99
100
100
The mapping can be partial. You only need to specify the model names that you want to override. If a mapping is provided, only the mapped url path is valid, and accessing to unmapped path will be denied.
101
101
102
+
- externalIdMapping
103
+
104
+
Optional. An `Record<string, string>` value that provides a mapping from model names (as defined in ZModel) to unique contraint name. This is useful when you for example want to expose natural keys in place of a surrogate keys:
105
+
106
+
```ts
107
+
// Expose tags by unique name and not by ID, ie. /tag/blue intead of /tag/id
108
+
RestApiHandler({
109
+
externalIdMapping: {
110
+
Tag: 'name'
111
+
}
112
+
})
113
+
```
114
+
115
+
Currentlly it is not possible to use custom index names. This also works for compound unique contraints just like for [compound IDs](#compound-id-fields).
0 commit comments