Skip to content

Commit 3f7dee4

Browse files
committed
Setting up Worker Bindings API chapters.
1 parent 192fa36 commit 3f7dee4

File tree

3 files changed

+35
-18
lines changed

3 files changed

+35
-18
lines changed

src/content/docs/d1/worker-api/query.mdx renamed to src/content/docs/d1/worker-api/handle-query-results.mdx

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
---
2-
title: D1 SQL statement methods
2+
title: Handle query results
33
pcx_content_type: concept
44
sidebar:
5-
order: 4
5+
order: 2
66
---
77

88
import { Type, MetaInfo, Details } from "~/components";
99

1010
## Description
1111

12-
D1 client API supports prepared and static statements. The best practice is to use prepared statements (which are precompiled objects used by the database) to run the SQL. Prepared statements lead to faster overall execution and prevent SQL injection attacks.
13-
14-
Below is an example of a prepared statement:
15-
16-
```js
17-
const stmt = db.prepare("SELECT * FROM users WHERE name = ?1").bind("Joe");
18-
```
19-
20-
However, if you still choose to use a static statement you can use the following as an example:
21-
22-
```js
23-
const stmt = db.prepare('SELECT * FROM users WHERE name = "John Doe"');
24-
```
25-
26-
You can subsequently combine the statements with the methods listed below.
12+
You can manipulate the query results which has been obtained after executing a `.db()` method.
2713

2814
## Methods
2915

src/content/docs/d1/worker-api/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
pcx_content_type: navigation
3-
title: Worker API
3+
title: Worker Bindings API
44
sidebar:
55
order: 4
66
group:
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
title: Prepare query statements
3+
pcx_content_type: concept
4+
sidebar:
5+
order: 1
6+
---
7+
8+
import { Type, MetaInfo, Details } from "~/components";
9+
10+
## Description
11+
12+
D1 client API supports both prepared and static statements. The best practice is to use prepared statements (which are precompiled objects used by the database) to run the SQL. Prepared statements lead to faster overall execution and prevent SQL injection attacks.
13+
14+
Below is an example of a prepared statement:
15+
16+
```js
17+
const stmt = db.prepare("SELECT * FROM users WHERE name = ?1").bind("Joe");
18+
```
19+
20+
However, if you still choose to use a static statement you can use the following as an example:
21+
22+
```js
23+
const stmt = db.prepare('SELECT * FROM users WHERE name = "John Doe"');
24+
```
25+
26+
## Methods
27+
28+
### db.prepare()
29+
30+
### db.batch()
31+

0 commit comments

Comments
 (0)