Skip to content

Commit 78733c1

Browse files
Oxyjunpedrosousa
andauthored
Apply suggestions from code review
Co-authored-by: Pedro Sousa <[email protected]>
1 parent 9b9a991 commit 78733c1

File tree

6 files changed

+8
-7
lines changed

6 files changed

+8
-7
lines changed

public/__redirects

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@
549549
/durable-objects/get-started/video-series/ /durable-objects/video-tutorials/ 301
550550

551551
/durable-objects/what-are-durable-objects/ /durable-objects/concepts/what-are-durable-objects/ 301
552-
/durable-objects/api/storage-api /durable-objects/api/sqlite-storage-api/ 301
552+
/durable-objects/api/storage-api/ /durable-objects/api/sqlite-storage-api/ 301
553553

554554
# email-routing
555555
/email-routing/enable-email-routing/ /email-routing/get-started/enable-email-routing/ 301

src/content/docs/durable-objects/api/sqlite-storage-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { Render, Type, MetaInfo, GlossaryTooltip, TypeScriptExample, Details } f
1010
:::note
1111
This page documents the storage API for the newer SQLite-backed Durable Objects.
1212

13-
For the legacy KV-backed Durable Object storage API, see [KV-backed Durable Object Storage (Legacy)](/durable-objects/api/legacy-kv-storage-api/).
13+
For the legacy KV-backed Durable Object storage API, refer to [KV-backed Durable Object Storage (Legacy)](/durable-objects/api/legacy-kv-storage-api/).
1414
:::
1515

1616
<Render file="api-storage-introduction" product="durable-objects" />

src/content/docs/durable-objects/api/state.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Tabs, TabItem, GlossaryTooltip, Type, MetaInfo } from "~/components";
1111

1212
The `DurableObjectState` interface is accessible as an instance property on the <GlossaryTooltip term="Durable Object class">Durable Object class</GlossaryTooltip>. This interface encapsulates methods that modify the state of a Durable Object, for example which WebSockets are attached to a Durable Object or how the runtime should handle concurrent Durable Object requests.
1313

14-
The `DurableObjectState` interface is different from the <GlossaryTooltip term="Storage API">Storage API</GlossaryTooltip> in that it does not have top-level methods which manipulate persistent application data. These methods are instead encapsulated in the [`DurableObjectStorage`](/durable-objects/api/sqlite-storage-api) interface and accessed by [`DurableObjectState::storage`](/durable-objects/api/state/#storage).
14+
The `DurableObjectState` interface is different from the <GlossaryTooltip term="Storage API">Storage API</GlossaryTooltip> in that it does not have top-level methods which manipulate persistent application data. These methods are instead encapsulated in the [`DurableObjectStorage`](/durable-objects/api/sqlite-storage-api/) interface and accessed by [`DurableObjectState::storage`](/durable-objects/api/state/#storage).
1515

1616
<Tabs> <TabItem label="JavaScript" icon="seti:javascript">
1717

src/content/partials/durable-objects/api-storage-other-methods.mdx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { Type, MetaInfo } from "~/components";
1919
- Invokes `callback()` wrapped in a transaction, and returns its result.
2020

2121
- If `callback()` throws an exception, the transaction will be rolled back.
22-
* The callback must complete synchronously, that is, it should not be declared `async` nor otherwise return a Promise. Only synchronous storage operations can be part of the transaction. This is intended for use with SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/sqlite-storage-api/#exec), which complete sychronously.
22+
23+
- The callback must complete synchronously, that is, it should not be declared `async` nor otherwise return a Promise. Only synchronous storage operations can be part of the transaction. This is intended for use with SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/sqlite-storage-api/#exec), which complete sychronously.
2324

2425
### `transaction`
2526

@@ -29,7 +30,7 @@ import { Type, MetaInfo } from "~/components";
2930
- Explicit transactions are no longer necessary. Any series of write operations with no intervening `await` will automatically be submitted atomically, and the system will prevent concurrent events from executing while `await` a read operation (unless you use `allowConcurrency: true`). Therefore, a series of reads followed by a series of writes (with no other intervening I/O) are automatically atomic and behave like a transaction.
3031

3132
- `txn`
32-
- Provides access to the `put()`, `get()`, `delete()` and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `ctx.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
33+
- Provides access to the `put()`, `get()`, `delete()`, and `list()` methods documented above to run in the current transaction context. In order to get transactional behavior within a transaction closure, you must call the methods on the `txn` Object instead of on the top-level `ctx.storage` Object.<br/><br/>Also supports a `rollback()` function that ensures any changes made during the transaction will be rolled back rather than committed. After `rollback()` is called, any subsequent operations on the `txn` Object will fail with an exception. `rollback()` takes no parameters and returns nothing to the caller.
3334

3435
- When using [the SQLite-backed storage engine](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), the `txn` object is obsolete. Any storage operations performed directly on the `ctx.storage` object, including SQL queries using [`ctx.storage.sql.exec()`](/durable-objects/api/sqlite-storage-api/#exec), will be considered part of the transaction.
3536

src/content/partials/durable-objects/api-sync-kv.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {Type, MetaInfo} from "~/components";
1414
- <code>ctx.storage.kv.put(key <Type text="string" />, value <Type text="any" />)</code>: <Type text="void" />
1515
- Stores the value and associates it with the given key. The value can be any type supported by the [structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm), which is true of most types.
1616

17-
The size of keys and values have different limits depending on the Durable Object storage backend you are using. Refer to either:
17+
The size of keys and values have different limits depending on the Durable Object storage backend you are using. Refer to:
1818
- [SQLite-backed Durable Object limits](/durable-objects/platform/limits/#sqlite-backed-durable-objects-general-limits)<br/><br/>
1919

2020
### `delete`

src/content/partials/durable-objects/storage-intro-text.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
The Durable Object Storage API comes with several methods, including [SQL API](/durable-objects/api/sqlite-storage-api/#sql-api), [point-in-time-recovery (PITR) API](/durable-objects/api/sqlite-storage-api/#pitr-point-in-time-recovery-api), and [key-value (KV) API](/durable-objects/api/sqlite-storage-api/#synchronous-kv-api).
66

7-
- Durable Object classes with the recommended, [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend) can use SQL API, PITR API, and KV API. KV API methods like `get()`, `put()`, `delete()`, or `list()` store data in a hidden SQLite table.
7+
- Durable Object classes with the recommended [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend) can use SQL API, PITR API, and KV API. KV API methods like `get()`, `put()`, `delete()`, or `list()` store data in a hidden SQLite table.
88
- Durable Objects gain access to a persistent KV Durable Object Storage API via the `DurableObjectStorage` interface and accessed by the `DurableObjectState::storage` property. This is frequently accessed via `this.ctx.storage` when the `ctx` parameter passed to the Durable Object constructor.
99
- Durable Object classes with the key-value storage backend can only use KV API.
1010

0 commit comments

Comments
 (0)