Skip to content

Commit f594203

Browse files
committed
Update docs
1 parent 9dcf5dd commit f594203

File tree

5 files changed

+103
-6
lines changed

5 files changed

+103
-6
lines changed

docs/api/databases.md

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,58 @@
88

99
**POST** <code>https://webhook.site/database/<span class="url-param">databaseId</span>/query</code>
1010

11-
* `query`: The SQL query to execute.
11+
* `query`: (string, required) The SQL query to execute.
12+
* `params`: (array|object) A list or dictionary of parameters. Can be left out if query has no parameters.
13+
14+
A maximum of 1000 results can be returned.
15+
16+
```json
17+
{
18+
"query": "select * from users where email like concat('%', :domain)",
19+
"params": {
20+
"domain": "@example.com"
21+
}
22+
}
23+
```
24+
25+
It is also possible to use a list of parameters:
1226

1327
```json
1428
{
15-
"query": "select * from mytable;"
29+
"query": "select * from users where email like concat('%', ?)",
30+
"params": [
31+
"@example.com"
32+
]
33+
}
34+
```
35+
36+
`params` can be left out if not needed:
37+
38+
```json
39+
{
40+
"query": "select * from users where email = '[email protected]'"
1641
}
1742
```
1843

1944
#### Response
2045

2146
* `result`: (array) The returned data.
22-
* `error`: (string) If the query results in an error, the error is represented here.
47+
* `error`: (string) If the query results in an error, the error is represented here, otherwise `null`.
2348
* `time`: (float) Query execution time in milliseconds.
2449

2550
```json
2651
{
2752
"result": [
2853
{
2954
"id": 1,
30-
"value": "hello world"
55+
"name": "Jack Daniels",
56+
"email": "[email protected]"
3157
},
3258
{
3359
"id": 2,
34-
"value": "it's a great day to be a query"
35-
}
60+
"name": "Elijah Craig",
61+
"email": "[email protected]"
62+
},
3663
],
3764
"error": null,
3865
"time": 0

docs/database.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ nav_order: 390
77

88
Store and process data in the Webhook.site Cloud using Databases. Built right in to Webhook.site, Databases provide a fully-featured PostgreSQL-compatible database. You can create and remove tables, create columns and run queries in the Console.
99

10+
<div class="center">
11+
<a href="https://webhook.site/control-panel/databases" class="md-button md-button--default no-underline">Create Database</a>
12+
</div>
13+
1014
With Webhook.site Custom Actions, you can interact with your Database to store, update, retrieve and remove data by SQL Query whenever a Webhook.site URL or E-mail Address receives a hit.
1115

1216
Additionally, with Webhook.site's simple API, you can manage your Database, including running SQL queries.

docs/news.markdown

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ Subscribe below to receive updates about improvements and new features on Webhoo
2424
</form>
2525
</div>
2626

27+
## 8 October 2025
28+
29+
* Added support for [Webhook.site Databases](/databases.html) in WebhookScript. [More info here](/webhookscript/functions/database.html).
30+
* Added `params` to the [Database Query API](/api/databases.html#run-query).
31+
* Increased maximum row count in Database actions to 1000.
32+
2733
## 1 October 2025
2834

2935
* New Feature: **Webhook.site Databases**, our new built-in database service hosted on the Webhook.site Cloud, is released to all users, and as an introductory offer, all Webhook.site Subscribers can create 1 DB-S instance for free. [More info here](/databases.html). <br> Create your Database now in Control Panel &rarr; [Databases](https://webhook.site/control-panel/databases).
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Database
2+
3+
### db(***string/int*** db_id) : function
4+
5+
The `db_id` parameter must either be the name or ID of a [Webhook.site Database](/database.html) instance.
6+
7+
When called directly, `db()` returns a Webhook.site Database instance in the form of a function that takes the following arguments: `query`, `params` and returns an array with the following keys: `result`, `error`, `time`.
8+
9+
```javascript
10+
// Connect to a Webhook.site Database instance
11+
mydb = db('mydb')
12+
13+
// You can use both numeric parameter names ...
14+
res = mydb(
15+
'insert into users (name, email) values (?, ?)',
16+
[
17+
get('request.query.name'),
18+
get('request.query.email')
19+
]
20+
)
21+
dump(res)
22+
// [
23+
// "result": [
24+
// 0: []
25+
// ],
26+
// "error": null,
27+
// "time": 0
28+
// ]
29+
30+
31+
// ... as well as named
32+
res = mydb(
33+
'select * from users where email = :email',
34+
[
35+
'email': get('request.query.email')
36+
]
37+
)
38+
dump(res)
39+
// [
40+
// "result": [
41+
// 0: [
42+
// "name": "example",
43+
// "email": "[email protected]"
44+
// ]
45+
// ],
46+
// "error": null,
47+
// "time": 0
48+
// ]
49+
50+
51+
// On error, the `error` key is set:
52+
res = db('select * from nonexisting_table')
53+
dump(res)
54+
// [
55+
// "result": null,
56+
// "error": "Undefined table: 7 ERROR: relation \"nonexisting\" does not exist",
57+
// "time": 0
58+
// ]
59+
```

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ nav:
8484
- Flow Control and Responses: webhookscript/functions/flow.md
8585
- Math and Numbers: webhookscript/functions/math.md
8686
- Network and HTTP: webhookscript/functions/network.md
87+
- Databases: webhookscript/functions/database.html
8788
- Strings: webhookscript/functions/string.md
8889
- Custom Action Variables: webhookscript/functions/variables.md
8990
- Examples: custom-actions/examples.markdown

0 commit comments

Comments
 (0)