Skip to content

Commit 3a2d0e5

Browse files
Oxyjunlambrospetrou
authored andcommitted
[D1] Updating D1Result object to include the new fields (cloudflare#22864)
* Updating D1Result object to include the new fields * Update src/content/docs/d1/worker-api/return-object.mdx Co-authored-by: Lambros Petrou <[email protected]> * Artificially changing served_by value --------- Co-authored-by: Lambros Petrou <[email protected]>
1 parent a6ecc64 commit 3a2d0e5

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ The methods [`D1PreparedStatement::run`](/d1/worker-api/prepared-statements/#run
2525
success: boolean, // true if the operation was successful, false otherwise
2626
meta: {
2727
served_by: string // the version of Cloudflare's backend Worker that returned the result
28+
served_by_region: string // the region of the database instance that executed the query
29+
served_by_primary: boolean // true if (and only if) the database instance that executed the query was the primary
30+
timings: {
31+
sql_duration_ms: number // the duration of the SQL query execution by the database instance (not including any network time)
32+
}
2833
duration: number, // the duration of the SQL query execution only, in milliseconds
2934
changes: number, // the number of changes made to the database
3035
last_row_id: number, // the last inserted row ID, only applies when the table is defined without the `WITHOUT ROWID` option
@@ -45,16 +50,21 @@ const stmt = env.DB.prepare("SELECT * FROM Customers WHERE CompanyName = ?").bin
4550
const returnValue = await stmt.run();
4651
return Response.json(returnValue)
4752
```
48-
```js
53+
```json
4954
{
5055
"success": true,
5156
"meta": {
5257
"served_by": "miniflare.db",
53-
"duration": 1,
58+
"served_by_region": "WEUR",
59+
"served_by_primary": true,
60+
"timings": {
61+
"sql_duration_ms": 0.2552
62+
},
63+
"duration": 0.2552,
5464
"changes": 0,
5565
"last_row_id": 0,
5666
"changed_db": false,
57-
"size_after": 8192,
67+
"size_after": 16384,
5868
"rows_read": 4,
5969
"rows_written": 0
6070
},

0 commit comments

Comments
 (0)