Skip to content

Commit

Permalink
Remove Atlas config option
Browse files Browse the repository at this point in the history
  • Loading branch information
Kalissaac committed Dec 1, 2020
1 parent 1d00ff6 commit e5d9b06
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 25 deletions.
7 changes: 0 additions & 7 deletions mongodb/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand Down Expand Up @@ -113,7 +107,6 @@ type Config struct {
```go
var ConfigDefault = Config{
Connection: "",
Atlas: false,
Host: "127.0.0.1",
Port: 27017,
Database: "fiber",
Expand Down
6 changes: 0 additions & 6 deletions mongodb/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
Expand Down
14 changes: 2 additions & 12 deletions mongodb/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand Down

0 comments on commit e5d9b06

Please sign in to comment.