update postgres connect example to non-deprecated (#973)

current docs show using a deprecated initializer that produces a
warning.
This commit is contained in:
Jared Henderson 2024-04-29 07:03:39 -04:00 committed by GitHub
parent e620dfd95f
commit 902c973c38
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 36 additions and 3 deletions

View File

@ -61,7 +61,18 @@ Una vez agregadas las dependencias, configura la base de datos con Fluent utiliz
import Fluent
import FluentPostgresDriver
app.databases.use(.postgres(hostname: "localhost", username: "vapor", password: "vapor", database: "vapor"), as: .psql)
app.databases.use(
.postgres(
configuration: .init(
hostname: "localhost",
username: "vapor",
password: "vapor",
database: "vapor",
tls: .disable
)
),
as: .psql
)
```
También se pueden expecificar las credenciales mediante una cadena de texto que defina la conexión a la base de datos.

View File

@ -61,7 +61,18 @@ Once the dependencies are added, configure the database's credentials with Fluen
import Fluent
import FluentPostgresDriver
app.databases.use(.postgres(hostname: "localhost", username: "vapor", password: "vapor", database: "vapor"), as: .psql)
app.databases.use(
.postgres(
configuration: .init(
hostname: "localhost",
username: "vapor",
password: "vapor",
database: "vapor",
tls: .disable
)
),
as: .psql
)
```
You can also parse the credentials from a database connection string.

View File

@ -61,7 +61,18 @@ PostgreSQL 是一个开源的、符合标准的 SQL 数据库。 它很容易在
import Fluent
import FluentPostgresDriver
app.databases.use(.postgres(hostname: "localhost", username: "vapor", password: "vapor", database: "vapor"), as: .psql)
app.databases.use(
.postgres(
configuration: .init(
hostname: "localhost",
username: "vapor",
password: "vapor",
database: "vapor",
tls: .disable
)
),
as: .psql
)
```
还可以从数据库连接字符串解析凭证。