Update mongodb.go

This commit is contained in:
Fenny
2020-11-05 05:31:57 +01:00
parent 7c9206a57e
commit 6fa1b0ebdb

View File

@@ -3,6 +3,7 @@ package mongodb
import ( import (
"context" "context"
"errors" "errors"
"fmt"
"net/url" "net/url"
"sync" "sync"
"time" "time"
@@ -46,6 +47,7 @@ func New(config ...Config) *Storage {
if cfg.Username != "" || cfg.Password != "" { if cfg.Username != "" || cfg.Password != "" {
dsn += "@" dsn += "@"
} }
dsn += fmt.Sprintf("%s:%d", url.QueryEscape(cfg.Host), cfg.Port)
// Set mongo options // Set mongo options
opt := options.Client() opt := options.Client()