Connecting with MongoDB
()
| 24 | //Connecting with MongoDB |
| 25 | |
| 26 | func init() { |
| 27 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| 28 | defer cancel() |
| 29 | client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoURL)) |
| 30 | checkNilErr(err) |
| 31 | |
| 32 | fmt.Println("MongoDB Connected sucessfully") |
| 33 | |
| 34 | collection = client.Database(databaseName).Collection(collectionName) |
| 35 | fmt.Println("Collection instance is ready") |
| 36 | |
| 37 | } |
| 38 | |
| 39 | // MONGODB HELPERS |
| 40 |
nothing calls this directly
no test coverage detected