Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsMongoDBURI ¶
IsMongoDBURI checks if the provided DSN is a MongoDB URI
Types ¶
type MongoDBConnection ¶
type MongoDBConnection struct {
Client *mongo.Client
Database *mongo.Database
// contains filtered or unexported fields
}
MongoDBConnection wraps a MongoDB client and database
func ConnectMongoDB ¶
func ConnectMongoDB(uri string, logger *slog.Logger) (*MongoDBConnection, error)
ConnectMongoDB connects to MongoDB using the provided URI The URI should be in the format: mongodb://[user:pass@]host[:port]/database[?options] or mongodb+srv://... for Atlas clusters
func ConnectMongoDBFromEnv ¶
func ConnectMongoDBFromEnv(logger *slog.Logger) (*MongoDBConnection, error)
ConnectMongoDBFromEnv reads MONGODB_URI or MONGO_URI env variable and connects to MongoDB. Returns (nil, nil) if no MongoDB URI is configured.
func (*MongoDBConnection) Close ¶
func (m *MongoDBConnection) Close(ctx context.Context) error
Close closes the MongoDB connection
func (*MongoDBConnection) Collection ¶
func (m *MongoDBConnection) Collection(name string) *mongo.Collection
Collection returns a collection handle for the specified collection name
func (*MongoDBConnection) TestRunsCollection ¶
func (m *MongoDBConnection) TestRunsCollection() *mongo.Collection
TestRunsCollection returns the test_runs collection handle
Click to show internal directories.
Click to hide internal directories.