Skip to content

Commit 0192bba

Browse files
authored
docs: clarify database connection options shape (#4465)
1 parent c1ff6ba commit 0192bba

1 file changed

Lines changed: 17 additions & 3 deletions

File tree

docs/1.docs/50.database.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,9 @@ const result = await stmt.bind("1001").all();
123123

124124
## Configuration
125125

126-
You can configure database connections using `database` config:
126+
You can configure database connections using `database` config.
127+
128+
Each connection is a `DatabaseConnectionConfig` with a `connector` name and an optional `options` object. Connector-specific settings (such as `url`, `host`, or `name`) belong under `options` — not at the top level of the connection config.
127129

128130
```ts [nitro.config.ts]
129131
import { defineConfig } from "nitro";
@@ -132,18 +134,30 @@ export default defineConfig({
132134
database: {
133135
default: {
134136
connector: "sqlite",
135-
options: { name: "db" }
137+
options: { name: "db" },
136138
},
137139
users: {
138140
connector: "postgresql",
139141
options: {
140-
url: "postgresql://username:password@hostname:port/database_name"
142+
url: "postgresql://username:password@hostname:port/database_name",
143+
},
144+
},
145+
analytics: {
146+
connector: "mysql2",
147+
options: {
148+
host: "localhost",
149+
port: 3306,
150+
user: "root",
151+
password: "password",
152+
database: "analytics",
141153
},
142154
},
143155
},
144156
});
145157
```
146158

159+
See the [db0 connector docs](https://db0.unjs.io/connectors) for the `options` each connector accepts.
160+
147161
### Development Database
148162

149163
Use the `devDatabase` config to override the database configuration **only for development mode**. This is useful for using a local SQLite database during development while targeting a different database in production.

0 commit comments

Comments
 (0)