Add support for MongoDB Atlas

This commit is contained in:
Kalissaac
2020-11-23 17:29:38 -08:00
parent 3f5230b6e5
commit d304cb36a9
2 changed files with 12 additions and 1 deletions

View File

@@ -33,7 +33,12 @@ func New(config ...Config) *Storage {
cfg := configDefault(config...)
// Create data source name
var dsn = "mongodb://"
var dsn = "mongodb"
if cfg.Atlas == true {
dsn += "+srv://"
} else {
dsn += "://"
}
if cfg.Username != "" {
dsn += url.QueryEscape(cfg.Username)
}