Skip to content

Commit

Permalink
fixed connection to DB with mongodb command if found occurrence
Browse files Browse the repository at this point in the history
  • Loading branch information
AxnNxs committed Jun 11, 2023
1 parent d353ede commit 09f01c4
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/webapi/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ func run() error {
var db database.AppDatabase

logger.Println("Initializing Database Support")
dbconn := options.Client().ApplyURI("mongodb://localhost:27017/")
mongo_url, found := os.LookupEnv("MONGO_URL")
if !(found) {
mongo_url = "mongodb://localhost:27017"
}
dbconn := options.Client().ApplyURI(mongo_url)
client, err := mongo.Connect(context.TODO(), dbconn)
if err != nil {
logger.WithError(err).Error("error connetting to mongo DB")
Expand Down

0 comments on commit 09f01c4

Please sign in to comment.