diff --git a/mongodb/README.md b/mongodb/README.md index 8ba261c7..8ea75589 100644 --- a/mongodb/README.md +++ b/mongodb/README.md @@ -41,7 +41,6 @@ store := mongodb.New() // Initialize custom config store := mongodb.New(mongodb.Config{ - Atlas: false, Host: "127.0.0.1", Port: 27017, Database: "fiber", @@ -67,11 +66,6 @@ type Config struct { // Optional. Default is "" Connection string - // Whether the DB is hosted on MongoDB Atlas - // - // Optional. Default is false - Atlas bool - // Host name where the DB is hosted // // Optional. Default is "127.0.0.1" @@ -113,7 +107,6 @@ type Config struct { ```go var ConfigDefault = Config{ Connection: "", - Atlas: false, Host: "127.0.0.1", Port: 27017, Database: "fiber", diff --git a/mongodb/config.go b/mongodb/config.go index 298ac8f0..7c11bda4 100644 --- a/mongodb/config.go +++ b/mongodb/config.go @@ -7,11 +7,6 @@ type Config struct { // Optional. Default is "" Connection string - // Whether the DB is hosted on MongoDB Atlas - // - // Optional. Default is false - Atlas bool - // Host name where the DB is hosted // // Optional. Default is "127.0.0.1" @@ -51,7 +46,6 @@ type Config struct { // ConfigDefault is the default config var ConfigDefault = Config{ Connection: "", - Atlas: false, Host: "127.0.0.1", Port: 27017, Database: "fiber", diff --git a/mongodb/mongodb.go b/mongodb/mongodb.go index 2af77c88..fc9c05cb 100644 --- a/mongodb/mongodb.go +++ b/mongodb/mongodb.go @@ -39,12 +39,7 @@ func New(config ...Config) *Storage { if cfg.Connection != "" { dsn = cfg.Connection } else { - dsn = "mongodb" - if cfg.Atlas { - dsn += "+srv://" - } else { - dsn += "://" - } + dsn = "mongodb://" if cfg.Username != "" { dsn += url.QueryEscape(cfg.Username) } @@ -54,12 +49,7 @@ func New(config ...Config) *Storage { if cfg.Username != "" || cfg.Password != "" { dsn += "@" } - // Cannot specify port when using MongoDB Atlas - if cfg.Atlas { - dsn += url.QueryEscape(cfg.Host) - } else { - dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port) - } + dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port) } // Set mongo options