mongodb

package
v0.0.0-...-9cb16bd Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package mongodb is a module for mongodb

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MongoDBContext

type MongoDBContext interface {
	// GetConn returns the mongodb connection
	GetConn() *mongo.Client

	// GetDatabase returns the mongodb database
	GetDatabase() *mongo.Database

	// Close closes the mongodb connection
	Close() error

	// Ping pings the mongodb connection
	Ping() error
}

func NewMongoDB

func NewMongoDB(opts ...Option) (MongoDBContext, error)

NewMongoDB creates a new mongodb connection

type MongoDBOptions

type MongoDBOptions struct {
	URI      string
	Database string
	Username string
	Password string
}

MongoDBOptions defines the mongo configuration

type Option

type Option func(*MongoDBOptions)

Option is the func interface to assign options

func WithMongoDBDatabase

func WithMongoDBDatabase(database string) Option

WithMongoDBDatabase defines the Mongo Connection Database

func WithMongoDBPassword

func WithMongoDBPassword(password string) Option

WithMongoDBPassword defines the Mongo Connection password

func WithMongoDBURI

func WithMongoDBURI(uri string) Option

WithMongoDBURI defines the Mongo Connection URI

func WithMongoDBUsername

func WithMongoDBUsername(username string) Option

WithMongoDBUsername defines the Mongo Connection Username

Directories

Path Synopsis
Package mongodb_mock is a generated GoMock package.
Package mongodb_mock is a generated GoMock package.

Jump to

Keyboard shortcuts

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