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
@@ -59,7 +59,7 @@ A cursor (`SqlStorageCursor`) to iterate over query row results as objects. `Sql
59
59
`SqlStorageCursor` supports the following methods:
60
60
61
61
*`next()`
62
-
* Returns an object representing the next value of the cursor. The returned object has `done` and `value` properties adhering to the JavaScript [Iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol). `done` is set to `false` when a next value is present, and `value` is set to the next row object in the query result. `done` is set to `true` when the entire cursor is consumed, and no `value` is set.
62
+
* Returns an object representing the next value of the cursor. The returned object has `done` and `value` properties adhering to the JavaScript [Iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_iterator_protocol). `done` is set to `false` when a next value is present, and `value` is set to the next row object in the query result. `done` is set to `true` when the entire cursor is consumed, and no `value` is set.
63
63
*`toArray()`
64
64
* Iterates through remaining cursor value(s) and returns an array of returned row objects.
65
65
*`one()`
@@ -70,17 +70,18 @@ A cursor (`SqlStorageCursor`) to iterate over query row results as objects. `Sql
70
70
* Returned cursor and `raw()` iterator iterate over the same query results and can be combined. For example:
71
71
72
72
```ts
73
-
let cursor =this.sql.exec("SELECT * FROM artist ORDER BY artistname ASC;");
74
-
let rawResult =cursor.raw().next();
73
+
let cursor =this.sql.exec("SELECT * FROM artist ORDER BY artistname ASC;");
74
+
let rawResult =cursor.raw().next();
75
75
76
-
if (!rawResult.done) {
77
-
console.log(rawResult.value); // prints [ 123, 'Alice' ]
78
-
} else {
79
-
// query returned zero results
80
-
}
76
+
if (!rawResult.done) {
77
+
console.log(rawResult.value); // prints [ 123, 'Alice' ]
* Returns a bookmark representing approximately the given point in time, which must be within the last 30 days. If the timestamp is represented as a number, it is converted to a date as if using `new Date(timestamp)`.
128
+
* Returns a bookmark representing approximately the given point in time, which must be within the last 30 days. If the timestamp is represented as a number, it is converted to a date as if using `new Date(timestamp)`.
127
129
128
130
### `onNextSessionRestoreBookmark`
129
131
@@ -135,8 +137,8 @@ The PITR API represents points in times using "bookmarks". A bookmark is a mostl
135
137
136
138
137
139
```ts
138
-
let now =newDate();
139
-
// restore to 2 days ago
140
-
let bookmark =ctx.storage.getBookmarkForTime(now-2);
Copy file name to clipboardExpand all lines: src/content/docs/durable-objects/api/storage-api.mdx
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,7 +43,7 @@ export class Counter {
43
43
44
44
:::note[SQLite in Durable Objects Beta]
45
45
46
-
The new beta version of Durable Objects is available where each Durable Object has a private, embedded SQLite database. When deploying a new Durable Object class, users can [opt-in to a SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend)in order to access new [SQL API](/durable-objects/api/sql-storage/#exec). Otherwise, a Durable Object class has a key-value storage backend.
46
+
The new beta version of Durable Objects is available where each Durable Object has a private, embedded SQLite database. When deploying a new Durable Object class, users can [opt-in to a SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend) to access the new [SQL API](/durable-objects/api/sql-storage/#exec). Otherwise, a Durable Object class has a key-value storage backend.
47
47
48
48
:::
49
49
@@ -209,7 +209,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
209
209
210
210
### `sync`
211
211
212
-
*`sync()`: <Typetext='Promise' />
212
+
*`sync()`: <Typetext='Promise' />
213
213
214
214
* Synchronizes any pending writes to disk.
215
215
@@ -247,7 +247,7 @@ The `put()` method returns a `Promise`, but most applications can discard this p
247
247
248
248
### `sql`
249
249
250
-
`sql` is a readonly property of type `DurableObjectStorage` encapsulating the [SQL API](/durable-objects/api/sql-storage).
250
+
`sql` is a readonly property of type `DurableObjectStorage` encapsulating the [SQL API](/durable-objects/api/sql-storage/).
- Adds a WebSocket to the set attached to this Durable Object. `ws.accept()` must not have been called separately. Once called, any incoming messages will be delivered by calling the Durable Object's `webSocketMessage()` handler, and `webSocketClose()` will be invoked upon disconnect.
0 commit comments