update mongodb official driver tutorial to its latest API (requires an options.ClientOptions instead of a simple url to connect to the server/host

Former-commit-id: 86ad73198016ce9d4b8c89ddb7191e932f759628
This commit is contained in:
Gerasimos (Makis) Maropoulos 2019-07-15 08:15:06 +03:00
parent 137c41344d
commit 2725267aa4

View File

@ -20,6 +20,7 @@ import (
"github.com/kataras/iris"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
const version = "0.0.1"
@ -35,7 +36,8 @@ func init() {
}
func main() {
client, err := mongo.Connect(context.Background(), env.DSN)
clientOptions := options.Client().SetHosts([]string{env.DSN})
client, err := mongo.Connect(context.Background(), clientOptions)
if err != nil {
log.Fatal(err)
}