You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
);INSERT INTO artist (artistid, artistname) VALUES
28
+
(123, 'Alice'),
29
+
(456, 'Bob'),
30
+
(789, 'Charlie');`
31
+
);
32
+
}
33
+
}
34
+
```
35
+
36
+
The `SqlStorage` interface is accessible via the `sql` property of `DurableObjectStorage` class.
37
+
11
38
:::note[SQLite in Durable Objects Beta]
12
39
SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Object classes with SQLite storage backend](/durable-objects/reference/durable-objects-migrations/#enable-sqlite-storage-backend-on-new-durable-object-class-migration) and will return an error if called on Durable Object classes with a key-value storage backend.
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/storage-api.mdx
+14-14Lines changed: 14 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -54,7 +54,7 @@ The Durable Object Storage API comes with several methods, including key-value (
54
54
55
55
Each method is implicitly wrapped inside a transaction, such that its results are atomic and isolated from all other storage operations, even when accessing multiple key-value pairs.
@@ -74,7 +74,7 @@ Each method is implicitly wrapped inside a transaction, such that its results ar
74
74
75
75
* If true, then the key/value will not be inserted into the in-memory cache. If the key is already in the cache, the cached value will be returned, but its last-used time will not be updated. Use this when you expect this key will not be used again in the near future. This flag is only a hint. This flag will never change the semantics of your code, but it may affect performance.
@@ -86,7 +86,7 @@ Each method is implicitly wrapped inside a transaction, such that its results ar
86
86
* Each 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.
87
87
* Supports up to 128 key-value pairs at a time. Each key is limited to a maximum size of 2,048 bytes and each value is limited to 128 KiB (131,072 bytes).
@@ -136,7 +136,7 @@ If you invoke `put()` (or `delete()`) multiple times without performing any `awa
136
136
The `put()` method returns a `Promise`, but most applications can discard this promise without using `await`. The `Promise` usually completes immediately, because `put()` writes to an in-memory write buffer that is flushed to disk asynchronously. However, if an application performs a large number of `put()` without waiting for any I/O, the write buffer could theoretically grow large enough to cause the isolate to exceed its 128 MB memory limit. To avoid this scenario, such applications should use `await` on the `Promise` returned by `put()`. The system will then apply backpressure onto the application, slowing it down so that the write buffer has time to flush. Using `await` will disable automatic write coalescing.
@@ -195,7 +195,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
195
195
196
196
* 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()`](#sqlexec), will be considered part of the transaction.
197
197
198
-
### transactionSync
198
+
### `transactionSync`
199
199
200
200
*`transactionSync(callback)`: <Typetext='any' />
201
201
@@ -207,15 +207,15 @@ The `put()` method returns a `Promise`, but most applications can discard this p
207
207
208
208
* 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()`](#sqlexec), which complete sychronously.
209
209
210
-
### sync
210
+
### `sync`
211
211
212
212
*`sync()` : <Typetext='Promise' />
213
213
214
214
* Synchronizes any pending writes to disk.
215
215
216
216
* This is similar to normal behavior from automatic write coalescing. If there are any pending writes in the write buffer (including those submitted with [the `allowUnconfirmed` option](/durable-objects/api/storage-api/#supported-options-1)), the returned promise will resolve when they complete. If there are no pending writes, the returned promise will be already resolved.
0 commit comments