Skip to content

Commit

Permalink
SQLite in DO clarifications:
Browse files Browse the repository at this point in the history
- deleteAll() behavior
- multi-statement queries with sql.exec
  • Loading branch information
vy-ton committed Oct 1, 2024
1 parent 9c0c0af commit ce1a0e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/content/docs/durable-objects/api/storage-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ Each method is implicitly wrapped inside a transaction, such that its results ar

* <code>deleteAll(options <Type text='Object' /> <MetaInfo text='optional' />)</code>: <Type text='Promise' />

* Deletes all keys and associated values, effectively deallocating all storage used by the Durable Object. In the event of a failure while the `deleteAll()` operation is still in flight, it may be that only a subset of the data is properly deleted. `deleteAll()` does not proactively delete [Alarms](/durable-objects/api/alarms/). Use [`deleteAlarm()`](/durable-objects/api/alarms/#deletealarm) to delete an alarm.
* Deletes all stored data, effectively deallocating all storage used by the Durable Object. For Durable Objects with a key-value storage backend, `deleteAll()` removes all keys and associated values for an individual Durable Object. For Durable Objects with a [SQLite storage backend](/durable-objects/best-practices/access-durable-objects-storage/#sqlite-storage-backend), `deleteAll()` removes the entire contents of a Durable Object's private SQLite database.
* In the event of a failure while the `deleteAll()` operation is still in flight, it may be that only a subset of the data is properly deleted.
* `deleteAll()` does not proactively delete [Alarms](/durable-objects/api/alarms/). Use [`deleteAlarm()`](/durable-objects/api/alarms/#deletealarm) to delete an alarm.

#### Supported options

Expand Down Expand Up @@ -245,7 +247,7 @@ SQL API methods accessed with `ctx.storage.sql` are only allowed on [Durable Obj

#### Parameters
* `query`: <Type text ='string' />
* The SQL query string to be executed. `query` can contain `?` placeholders for parameter bindings.
* The SQL query string to be executed. `query` can contain `?` placeholders for parameter bindings. Multiple SQL statements, separated with a semicolen, can be executed in the `query`; any parameter bindings are applied to the last SQL statement in the `query`.
* `bindings`: <Type text='any[]' /> <MetaInfo text='Optional' />
* Optional variable number of arguments that correspond to the `?` placeholders in `query`.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export class Counter extends DurableObject {
}
}
```
### Removing a Durable Object's storage

To effectively "delete" a Durable Object, you should first use [`deleteAll()`](/durable-objects/api/storage-api/#deleteall) to remove any attached storage for a Durable Object. Calling `deleteAll()` ensures that a Durable Object will not be [billed for Storage API usage](/durable-objects/platform/pricing/#storage-api-billing). Once storage is delete and a Durable Objecy is no longer active due to incoming requests, then the Durable Object is effectively deleted.

## SQLite storage backend

Expand Down

0 comments on commit ce1a0e3

Please sign in to comment.