mongo

package
v1.13.0-beta.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 29, 2025 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package mongo provides MongoDB connection and operation utilities. It includes connection management, query helpers, and database operations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoConnection

type MongoConnection struct {
	ConnectionStringSource string
	DB                     *mongo.Client
	Connected              bool
	Database               string
	Logger                 log.Logger
	MaxPoolSize            uint64
}

MongoConnection is a hub which deal with mongodb connections. The type name intentionally matches the package name for clarity in external usage.

func (*MongoConnection) Connect

func (mc *MongoConnection) Connect(ctx context.Context) error

Connect keeps a singleton connection with mongodb.

func (*MongoConnection) GetDB

func (mc *MongoConnection) GetDB(ctx context.Context) (*mongo.Client, error)

GetDB returns a pointer to the mongodb connection, initializing it if necessary.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL