Skip to content

Commit 236aad9

Browse files
committed
Turning all method names into links to the relevant header.
1 parent cc0de6f commit 236aad9

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ const stmt = env.DB.prepare("SELECT * FROM Customers WHERE CompanyName = ?").bin
4646
| `?NNN` | Ordered | A question mark followed by a number `NNN` holds a spot for the `NNN`-th parameter. `NNN` must be between `1` and `SQLITE_MAX_VARIABLE_NUMBER` |
4747
| `?` | Anonymous | A question mark that is not followed by a number creates a parameter with a number one greater than the largest parameter number already assigned. If this means the parameter number is greater than `SQLITE_MAX_VARIABLE_NUMBER`, it is an error. This parameter format is provided for compatibility with other database engines. But because it is easy to miscount the question marks, the use of this parameter format is discouraged. Programmers are encouraged to use one of the symbolic formats below or the `?NNN` format above instead. |
4848

49-
To bind a parameter, use the `D1PreparedStatement::bind` method.
49+
To bind a parameter, use the `.bind` method.
5050

5151
Order and anonymous examples:
5252

@@ -117,7 +117,7 @@ const batchResult = await env.DB.batch([
117117
#### Return values
118118

119119
- <code>results</code>: <Type text="Array"/>
120-
- An array of `D1Result` objects containing the results of the `D1Database::prepare` statements. Each object is in the array position corresponding to the array position of the initial `D1Database::prepare` statement within the `statements`.
120+
- An array of `D1Result` objects containing the results of the [`D1Database::prepare`](#prepare) statements. Each object is in the array position corresponding to the array position of the initial [`D1Database::prepare`](#prepare) statement within the `statements`.
121121
- Refer to [`D1Result`](/d1/worker-api/return-object/#d1result) for more information about this object.
122122

123123
<Details header="Example of return values" open={false}>

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ Refer to the relevant sections for the API documentation.
2020

2121
D1 Worker Bindings API is fully-typed via the [`@cloudflare/workers-types`](/workers/languages/typescript/#typescript) package, and also supports [generic types](https://www.typescriptlang.org/docs/handbook/2/generics.html#generic-types) as part of its TypeScript API. A generic type allows you to provide an optional `type parameter` so that a function understands the type of the data it is handling.
2222

23-
When using the [query statement methods](/d1/worker-api/prepared-statements) `D1PreparedStatement::run`, `D1PreparedStatement::raw` and `D1PreparedStatement::first`, you can provide a type representing each database row. D1's API will [return the result object](#return-object) with the correct type.
23+
When using the query statement methods [`D1PreparedStatement::run`](/d1/worker-api/prepared-statements/#run), [`D1PreparedStatement::raw`](/d1/worker-api/prepared-statements/#raw) and [`D1PreparedStatement::first`](/d1/worker-api/prepared-statements/#first), you can provide a type representing each database row. D1's API will [return the result object](#return-object) with the correct type.
2424

25-
For example, providing an `OrderRow` type as a type parameter to `D1PreparedStatement::run` will return a typed `Array<OrderRow>` object instead of the default `Record<string, unknown>` type:
25+
For example, providing an `OrderRow` type as a type parameter to [`D1PreparedStatement::run`](/d1/worker-api/prepared-statements/#run) will return a typed `Array<OrderRow>` object instead of the default `Record<string, unknown>` type:
2626

2727
```ts
2828
// Row definition

src/content/docs/d1/worker-api/prepared-statements.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ return Response.json(returnValue);
7070
#### Guidance
7171

7272
- `results` is empty for write operations such as `UPDATE`, `DELETE`, or `INSERT`.
73-
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to `D1PreparedStatement::run` to return a typed result object.
74-
- `D1PreparedStatement::run` is functionally equivalent to `D1PreparedStatement::all`, and can be treated as an alias.
73+
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to [`D1PreparedStatement::run`](#run) to return a typed result object.
74+
- [`D1PreparedStatement::run`](#run) is functionally equivalent to `D1PreparedStatement::all`, and can be treated as an alias.
7575
- You can choose to extract only the results you expect from the statement by simply returning the `results` property of the return object.
7676

7777
<Details header="Example of returning only the `results`" open={false}>
@@ -158,7 +158,7 @@ return Response.json(returnValue)
158158

159159
#### Guidance
160160

161-
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to `D1PreparedStatement::raw` to return a typed result array.
161+
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to [`D1PreparedStatement::raw`](#raw) to return a typed result array.
162162

163163
### `first()`
164164

@@ -217,7 +217,7 @@ return Response.json(returnValue)
217217

218218
#### Guidance
219219

220-
- If the query returns rows but `column` does not exist, then `D1PreparedStatement::first` throws the `D1_ERROR` exception.
221-
- `D1PreparedStatement::first` does not alter the SQL query. To improve performance, consider appending `LIMIT 1` to your statement.
222-
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to `D1PreparedStatement::first` to return a typed result object.
220+
- If the query returns rows but `column` does not exist, then [`D1PreparedStatement::first`](#first) throws the `D1_ERROR` exception.
221+
- [`D1PreparedStatement::first`](#first) does not alter the SQL query. To improve performance, consider appending `LIMIT 1` to your statement.
222+
- When using TypeScript, you can pass a [type parameter](/d1/build-with-d1/d1-client-api/#typescript-support) to [`D1PreparedStatement::first`](#first) to return a typed result object.
223223

src/content/docs/d1/worker-api/return-object.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ sidebar:
77

88
Some D1 Worker Binding APIs return a typed object.
99

10-
| D1 Worker Binding API | Return object |
11-
| ---------------------------------------------- | ------------- |
12-
| `D1PreparedStatement::run`, `D1Database::batch`| `D1Result` |
13-
| `D1Database::exec` | `D1ExecResult`|
10+
| D1 Worker Binding API | Return object |
11+
| ------------------------------------------------------------------------------------------------------------------------------ | ------------- |
12+
| [`D1PreparedStatement::run`](/d1/worker-api/prepared-statements/#run), [`D1Database::batch`](/d1/worker-api/d1-database/#batch)| `D1Result` |
13+
| [`D1Database::exec`](/d1/worker-api/d1-database/#exec) | `D1ExecResult`|
1414

1515
## D1Result
1616

17-
The methods `D1PreparedStatement::run` and `D1Database::batch` return a typed `D1Result` object for each query statement. This object contains:
17+
The methods [`D1PreparedStatement::run`](/d1/worker-api/prepared-statements/#run) and [`D1Database::batch`](/d1/worker-api/d1-database/#batch) return a typed [`D1Result`](#d1result) object for each query statement. This object contains:
1818

1919
- The success status
2020
- A meta object with the internal duration of the operation in milliseconds
@@ -75,7 +75,7 @@ return Response.json(result)
7575

7676
## D1ExecResult
7777

78-
The method `D1Database::exec` returns a typed `D1ExecResult` object for each query statement. This object contains:
78+
The method [`D1Database::exec`](/d1/worker-api/d1-database/#exec) returns a typed [`D1ExecResult`](#d1execresult) object for each query statement. This object contains:
7979

8080
- The number of executed queries
8181
- The duration of the operation in milliseconds

0 commit comments

Comments
 (0)