web-sqlite-js 1.0.2 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -33,6 +33,7 @@ Designed to be truly effortless, it allows you to get a high-performance relatio
|
|
|
33
33
|
- [Quick start](#quick-start)
|
|
34
34
|
- [Setup HTTP headers](#setup-http-headers)
|
|
35
35
|
- [Usage](#usage)
|
|
36
|
+
- [Debug mode](#debug-mode)
|
|
36
37
|
- [Transactions](#transactions)
|
|
37
38
|
|
|
38
39
|
## Features
|
|
@@ -65,7 +66,7 @@ For quick demos or plain HTML pages you can load the prebuilt module directly:
|
|
|
65
66
|
|
|
66
67
|
```html
|
|
67
68
|
<script type="module">
|
|
68
|
-
import openDB from "https://cdn.jsdelivr.net/npm/web-sqlite-js@1.0.
|
|
69
|
+
import openDB from "https://cdn.jsdelivr.net/npm/web-sqlite-js@1.0.4/dist/index.js";
|
|
69
70
|
// ...
|
|
70
71
|
</script>
|
|
71
72
|
```
|
|
@@ -244,6 +245,21 @@ console.log(users);
|
|
|
244
245
|
await db.close();
|
|
245
246
|
```
|
|
246
247
|
|
|
248
|
+
## Debug mode
|
|
249
|
+
|
|
250
|
+
Add `{ debug: true }` when opening the database to stream worker-side SQL logs (including bind values and timings) to your browser's `console.debug`. This is useful for profiling and verifying queries during development.
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
const db = await openDB("local.sqlite3", { debug: true });
|
|
254
|
+
|
|
255
|
+
await db.exec("CREATE TABLE IF NOT EXISTS notes (body TEXT)");
|
|
256
|
+
await db.query("SELECT * FROM notes WHERE id = ?", [1]);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
The console output highlights SQL keywords and shows how long each statement took (click to preview):
|
|
260
|
+
|
|
261
|
+
[](docs/assets/debug.png)
|
|
262
|
+
|
|
247
263
|
#### Transactions
|
|
248
264
|
|
|
249
265
|
Transactions are atomic. If any command inside the callback fails, the entire transaction is rolled back.
|
|
@@ -259,3 +275,7 @@ await db.transaction(async (tx) => {
|
|
|
259
275
|
// throw new Error('Something went wrong');
|
|
260
276
|
});
|
|
261
277
|
```
|
|
278
|
+
|
|
279
|
+
## Star History
|
|
280
|
+
|
|
281
|
+
[](https://www.star-history.com/#wuchuheng/web-sqlite-js&type=date&legend=top-left)
|
package/package.json
CHANGED