Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1355,7 +1355,7 @@ select ''csv'' as component, ''example.csv'' as filename;
SELECT * FROM my_large_table;
```

#### `index.sql`
Link to `csv_download.sql` from a separate page with the button below. Opening the link starts the download without embedding the CSV data in the page that contains the button.
',
json('[{"component":"button"}, {"title": "Download my data", "link": "/examples/csv_download.sql"}]')),
('csv', '
Expand Down
8 changes: 4 additions & 4 deletions examples/official-site/sqlpage/migrations/05_cookie.sql
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,20 @@ VALUES (
INSERT INTO example (component, description)
VALUES (
'cookie',
'Create a cookie named `username` with the value `John Doe`...
'Set the cookie before producing any page content:

```sql
SELECT ''cookie'' as component,
''username'' as name,
''John Doe'' as value
''John Doe'' as value,
FALSE AS secure; -- You can remove this if the site is served over HTTPS.
```

and then display the value of the cookie using the [`sqlpage.cookie`](functions.sql?function=cookie) function:
On a later request, read the value the browser sent with [`sqlpage.cookie`](functions.sql?function=cookie). Setting a response cookie does not change the current request.

```sql
SELECT ''text'' as component,
''Your name is '' || COALESCE(sqlpage.cookie(''username''), ''not known to us'');
''Your name is '' || COALESCE(sqlpage.cookie(''username''), ''not known to us'') as contents;
```
'
);
4 changes: 2 additions & 2 deletions examples/official-site/sqlpage/migrations/11_json.sql
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,12 @@ curl -H "Accept: application/json" http://localhost:8080/users.sql
(
'json',
'
## Send a single JSON object: `''jsonlines'' as type`
## Send one JSON object per row: `''jsonlines'' as type`

In `jsonlines` mode, each query result is rendered as a JSON object in a separate line,
without a top-level array.

If there is a single query result, the response will be a valid JSON object.
If there are no rows, the response body is empty. If there is a single row, the response is a JSON object.
If there are multiple query results, you will need to parse each line of the response as a separate JSON object.

If a query returns an error, the response will be a JSON object with an `error` property.
Expand Down
Loading