mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 16:22:52 +08:00
Simplify if statements
This commit is contained in:
@@ -34,7 +34,7 @@ func New(config ...Config) *Storage {
|
|||||||
|
|
||||||
// Create data source name
|
// Create data source name
|
||||||
var dsn = "mongodb"
|
var dsn = "mongodb"
|
||||||
if cfg.Atlas == true {
|
if cfg.Atlas {
|
||||||
dsn += "+srv://"
|
dsn += "+srv://"
|
||||||
} else {
|
} else {
|
||||||
dsn += "://"
|
dsn += "://"
|
||||||
@@ -48,8 +48,9 @@ func New(config ...Config) *Storage {
|
|||||||
if cfg.Username != "" || cfg.Password != "" {
|
if cfg.Username != "" || cfg.Password != "" {
|
||||||
dsn += "@"
|
dsn += "@"
|
||||||
}
|
}
|
||||||
if cfg.Atlas == true {
|
// Cannot specify port when using MongoDB Atlas
|
||||||
dsn += url.QueryEscape(cfg.Host) // Cannot specify port when using MongoDB Atlas
|
if cfg.Atlas {
|
||||||
|
dsn += url.QueryEscape(cfg.Host)
|
||||||
} else {
|
} else {
|
||||||
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user