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
Copy file name to clipboardExpand all lines: README.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,6 +25,7 @@ Some of the big supported features:
25
25
- Custom tokenizers
26
26
- Load runtime extensions
27
27
- JSONB support
28
+
- Native query interruption via `db.interrupt()`
28
29
29
30
It also contains a simple [Key-Value store](https://op-engineering.github.io/op-sqlite/docs/key_value_storage) you can use without adding one more dependency to your app.
Copy file name to clipboardExpand all lines: docs/docs/api.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -120,6 +120,28 @@ On web, `execute()` runs the full SQL string passed to it.
120
120
On native, `execute()` currently runs only the first prepared statement.
121
121
If you need identical behavior across platforms, avoid multi-statement SQL strings.
122
122
123
+
## Interrupting a Query
124
+
125
+
On native, `interrupt()` aborts any pending database operation on this connection. It is safe to call from a thread different from the one running the operation. The interrupted query returns `SQLITE_INTERRUPT`; any in-flight transaction is rolled back. This calls SQLite's native [`sqlite3_interrupt()`](https://sqlite.org/c3ref/interrupt.html).
126
+
127
+
`interrupt()` is not available when op-sqlite is built with the `libsql` or `turso` backend.
128
+
129
+
```tsx
130
+
const query =db.execute(longRunningQuery);
131
+
132
+
setTimeout(() => {
133
+
db.interrupt();
134
+
}, 100);
135
+
136
+
try {
137
+
awaitquery;
138
+
} catch (error) {
139
+
// SQLITE_INTERRUPT
140
+
}
141
+
```
142
+
143
+
On web, `interrupt()` is not supported.
144
+
123
145
### Execute with Host Objects
124
146
125
147
It’s possible to return HostObjects when using a query. The benefit is that HostObjects are only created in C++ and only when you try to access a value inside of them a C++ value → JS value conversion happens. This means creation is fast, property access is slow. The use case is clear if you are returning **massive** amount of objects but only displaying/accessing a few of them at the time.
0 commit comments