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: SCHEMA.md
+36-9Lines changed: 36 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -84,6 +84,7 @@ global_helpers:
84
84
| `js` | string | Inline JavaScript code |
85
85
| `js_files` | string[] | Paths to JavaScript files (relative to config) |
86
86
87
+
> [!TIP]
87
88
> **Shorthand:** `global_helpers: |` is equivalent to `global_helpers: { js: | }`
88
89
89
90
## CSV Config
@@ -107,7 +108,10 @@ The `value_parser` function receives `value` (string) and should return the pars
107
108
108
109
## Queries
109
110
110
-
Query endpoints for SELECT operations. Each query must have either `sql` OR [`mock`](#mock), not both.
111
+
Query endpoints for SELECT operations.
112
+
113
+
> [!IMPORTANT]
114
+
> Each query must have either `sql` OR [`mock`](#mock), not both.
111
115
112
116
```yaml
113
117
queries:
@@ -138,6 +142,9 @@ queries:
138
142
| `one` | Returns a single row as an object. Returns 404 if not found (or `null` to post with `handle_not_found: true`) |
139
143
| `many` | Returns multiple rows as an array. Returns empty array `[]` if no rows found |
140
144
145
+
> [!TIP]
146
+
> Use `handle_not_found: true` to handle not-found cases in post-transform (e.g., return a default object instead of 404).
147
+
141
148
### Query Method
142
149
143
150
| Value | Description |
@@ -150,7 +157,13 @@ queries:
150
157
151
158
## Mutations
152
159
153
-
Mutation endpoints for INSERT/UPDATE/DELETE operations. Each mutation (type: one/many) must have either `sql` OR [`mock`](#mock), not both. Type: none requires `sql`.
160
+
Mutation endpoints for INSERT/UPDATE/DELETE operations.
161
+
162
+
> [!IMPORTANT]
163
+
> Each mutation (type: one/many) must have either `sql` OR [`mock`](#mock), not both.
164
+
165
+
> [!WARNING]
166
+
> `type: none` requires `sql` — mock is not supported.
> Note: `type: none` requires `sql` - [mock](#mock) is not supported for type: none.
176
188
177
189
### Mutation Type
178
190
@@ -193,7 +205,10 @@ mutations:
193
205
194
206
### MySQL-Specific Behavior
195
207
196
-
For MySQL, mutations use `Exec` instead of `Query` since MySQL does not support `RETURNING` clause. This makes `ctx.lastInsertId` and `ctx.rowsAffected` available in [post-transform](#post-transform):
208
+
> [!WARNING]
209
+
> MySQL does not support `RETURNING` clause. Use `ctx.lastInsertId` and `ctx.rowsAffected` in post-transform instead.
210
+
211
+
For MySQL, mutations use `Exec` instead of `Query`. This makes `ctx.lastInsertId` and `ctx.rowsAffected` available in [post-transform](#post-transform):
197
212
198
213
```yaml
199
214
mutations:
@@ -210,6 +225,7 @@ mutations:
210
225
| `ctx.lastInsertId` | Auto-increment ID from INSERT | `undefined` |
211
226
| `ctx.rowsAffected` | Number of affected rows | `undefined` |
212
227
228
+
> [!TIP]
213
229
> For PostgreSQL, SQLite, and SQL Server, use `RETURNING *` clause instead to get inserted data directly.
214
230
215
231
## Mock
@@ -220,7 +236,8 @@ Mock is specified at the [query](#queries)/[mutation](#mutations) level (same le
220
236
221
237
### Mock Sources
222
238
223
-
**Only one source type can be specified per mock.**
239
+
> [!IMPORTANT]
240
+
> Only one source type can be specified per mock.
224
241
225
242
#### Object Sources (type: one only)
226
243
@@ -289,7 +306,10 @@ mock:
289
306
290
307
### Filter
291
308
292
-
The `filter` option allows filtering array data using JavaScript. For `type: one` with [array sources](#array-sources-type-many-or-type-one-with-filter), `filter` is **required** to select which row to return.
309
+
The `filter` option allows filtering array data using JavaScript.
310
+
311
+
> [!IMPORTANT]
312
+
> For `type: one` with [array sources](#array-sources-type-many-or-type-one-with-filter), `filter` is **required** to select which row to return.
293
313
294
314
**Filter variables:**
295
315
- `row` (parameter): Current row being evaluated
@@ -433,6 +453,7 @@ post:
433
453
return { items: output };
434
454
```
435
455
456
+
> [!TIP]
436
457
> **Shorthand:** `post: |` is equivalent to `post: { all: | }`
437
458
438
459
## Error Handling
@@ -446,6 +467,9 @@ pre: |
446
467
}
447
468
```
448
469
470
+
> [!NOTE]
471
+
> If you throw without `status`, the default depends on the phase:
472
+
449
473
| Phase | Default Status |
450
474
|-------|----------------|
451
475
| [`pre`](#pre-transform) | 400 Bad Request |
@@ -467,7 +491,8 @@ queries:
467
491
sql: SELECT * FROM posts WHERE user_id = :user_id
468
492
```
469
493
470
-
**Priority:** Path parameters take precedence over query string and body parameters.
494
+
> [!CAUTION]
495
+
> Path parameters take precedence over query string and body parameters. If both exist, the path parameter wins.
471
496
472
497
```yaml
473
498
# Request: GET /users/42?id=999
@@ -530,7 +555,8 @@ For common patterns, use `{param:*shorthand*}` syntax:
530
555
sql: SELECT * FROM events WHERE id = :id
531
556
```
532
557
533
-
The `*...*` syntax is unambiguous because `*` at the start of a regex is invalid.
558
+
> [!NOTE]
559
+
> The `*...*` syntax is unambiguous because `*` at the start of a regex is invalid.
534
560
535
561
## Named Placeholders
536
562
@@ -562,4 +588,5 @@ accepts: form # Only application/x-www-form-urlencoded
562
588
accepts: [json, form] # Both (default)
563
589
```
564
590
565
-
Returns 415 Unsupported Media Type if the request Content-Type doesn't match.
591
+
> [!WARNING]
592
+
> Returns 415 Unsupported Media Type if the request Content-Type doesn't match.
0 commit comments