initial commit
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user