chore(db): controller verifies connection with mongoDB
This commit is contained in:
parent
9bf77a6a8e
commit
75603c6f6f
|
|
@ -20,6 +20,11 @@ func NewDatabase(ctx context.Context, mongoUri string) Database {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
log.Println("Trying to ping Mongo database...")
|
||||||
|
err = client.Ping(ctx, nil)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal("Couldn't connect to MongoDB --> ", err)
|
||||||
|
}
|
||||||
|
|
||||||
log.Println("Connected to MongoDB-->", mongoUri)
|
log.Println("Connected to MongoDB-->", mongoUri)
|
||||||
devices := client.Database("oktopus").Collection("devices")
|
devices := client.Database("oktopus").Collection("devices")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user