From 654d33620a0cde1878ecaa92c1d09c20c0b92c3f Mon Sep 17 00:00:00 2001 From: Alistair Smith Date: Mon, 25 Aug 2025 17:37:02 -0700 Subject: [PATCH] fix accordions in sql docs (#22134) --- docs/api/sql.md | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/docs/api/sql.md b/docs/api/sql.md index e033fe0916..ca630ec3f9 100644 --- a/docs/api/sql.md +++ b/docs/api/sql.md @@ -90,8 +90,7 @@ const db2 = new SQL({ const db3 = new SQL("myapp.db", { adapter: "sqlite" }); ``` -
-SQLite Connection String Formats +{% details summary="SQLite Connection String Formats" %} SQLite accepts various URL formats for connection strings: @@ -122,10 +121,9 @@ new SQL("sqlite://data.db?mode=rwc"); // Read-write-create mode (default) **Note:** Simple filenames without a protocol (like `"myapp.db"`) require explicitly specifying `{ adapter: "sqlite" }` to avoid ambiguity with PostgreSQL. -
+{% /details %} -
-SQLite-Specific Options +{% details summary="SQLite-Specific Options" %} SQLite databases support additional configuration options: @@ -151,7 +149,7 @@ Query parameters in the URL are parsed to set these options: - `?mode=rw` → `readonly: false, create: false` - `?mode=rwc` → `readonly: false, create: true` (default) -
+{% /details %} ### Inserting data @@ -532,15 +530,14 @@ const db = new SQL({ }); ``` -
-SQLite Connection Notes +{% details summary="SQLite Connection Notes" %} - **Connection Pooling**: SQLite doesn't use connection pooling as it's a file-based database. Each `SQL` instance represents a single connection. - **Transactions**: SQLite supports nested transactions through savepoints, similar to PostgreSQL. - **Concurrent Access**: SQLite handles concurrent access through file locking. Use WAL mode for better concurrency. - **Memory Databases**: Using `:memory:` creates a temporary database that exists only for the connection lifetime. -
+{% /details %} ## Dynamic passwords @@ -838,6 +835,8 @@ try { } ``` +{% details summary="PostgreSQL-Specific Error Codes" %} + ### PostgreSQL Connection Errors | Connection Errors | Description | @@ -903,12 +902,13 @@ try { | `ERR_POSTGRES_UNSAFE_TRANSACTION` | Unsafe transaction operation detected | | `ERR_POSTGRES_INVALID_TRANSACTION_STATE` | Invalid transaction state | +{% /details %} + ### SQLite-Specific Errors SQLite errors provide error codes and numbers that correspond to SQLite's standard error codes: -
-Common SQLite Error Codes +{% details summary="Common SQLite Error Codes" %} | Error Code | errno | Description | | ------------------- | ----- | ---------------------------------------------------- | @@ -945,7 +945,7 @@ try { } ``` -
+{% /details %} ## Numbers and BigInt @@ -998,13 +998,7 @@ We also haven't implemented some of the more uncommon features like: - Point & PostGIS types - All the multi-dimensional integer array types (only a couple of the types are supported) -## Frequently Asked Questions - -> Why is this `Bun.sql` and not `Bun.postgres`? - -The plan is to add more database drivers in the future. - -> Why not just use an existing library? +## Why not just use an existing library? npm packages like postgres.js, pg, and node-postgres can be used in Bun too. They're great options.