20 lines
354 B
Go
20 lines
354 B
Go
package app
|
|
|
|
import (
|
|
"log"
|
|
|
|
"go.mongodb.org/mongo-driver/v2/mongo"
|
|
"go.mongodb.org/mongo-driver/v2/mongo/options"
|
|
)
|
|
|
|
func (a *App) initMongo() {
|
|
if a.config.mongoURI == "" {
|
|
return
|
|
}
|
|
client, err := mongo.Connect(options.Client().ApplyURI(a.config.mongoURI))
|
|
if err != nil {
|
|
log.Fatalln("failed to connect mongo:", err)
|
|
}
|
|
a.mongo = client
|
|
}
|