Add Postgres and MySQL connection strings (#429)

* Add ConnectionURI to Postgres

* Add ConnectionURI to MySQL

* Update Postgres sample db name
This commit is contained in:
Kalissaac
2022-08-14 22:48:29 -07:00
committed by GitHub
parent d27ddd4739
commit c38c925975
5 changed files with 64 additions and 18 deletions

View File

@@ -49,12 +49,24 @@ store := postgres.New(postgres.Config{
GCInterval: 10 * time.Second,
SslMode: "disable",
})
// Initialize custom config using connection string
store := postgres.New(postgres.Config{
ConnectionURI: "postgresql://user:password@localhost:5432/fiber"
Reset: false,
GCInterval: 10 * time.Second,
})
```
### Config
```go
// Config defines the config for storage.
type Config struct {
// Connection string to use for DB. Will override all other authentication values if used
//
// Optional. Default is ""
ConnectionURI string
// Host name where the DB is hosted
//
// Optional. Default is "127.0.0.1"
@@ -105,6 +117,7 @@ type Config struct {
### Default Config
```go
var ConfigDefault = Config{
ConnectionURI: "",
Host: "127.0.0.1",
Port: 5432,
Database: "fiber",