MongoDB creates a *mongo.Database connection to MongoDB Atlas
()
| 291 | |
| 292 | // MongoDB creates a *mongo.Database connection to MongoDB Atlas |
| 293 | func (container *Container) MongoDB() *mongoDriver.Database { |
| 294 | if container.mongoDB != nil { |
| 295 | return container.mongoDB |
| 296 | } |
| 297 | |
| 298 | container.logger.Debug("creating MongoDB *mongo.Database connection") |
| 299 | |
| 300 | db, err := repositories.NewMongoDB(os.Getenv("MONGODB_URI")) |
| 301 | if err != nil { |
| 302 | container.logger.Fatal(err) |
| 303 | } |
| 304 | |
| 305 | container.mongoDB = db |
| 306 | return container.mongoDB |
| 307 | } |
| 308 | |
| 309 | // DBWithoutMigration creates an instance of gorm.DB if it has not been created already |
| 310 | func (container *Container) DBWithoutMigration() (db *gorm.DB) { |
no test coverage detected