mongodb

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package mongodb provides a MongoDB client connection with optional TLS.

Index

Constants

View Source
const (
	ErrCodeReadCertFile = "MNG-001"
	ErrCodeAppendCert   = "MNG-002"
	ErrCodeConnection   = "MNG-003"
)

Variables

View Source
var (
	ErrReadCertFile = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeReadCertFile, "certificate file reading error").Wrap(cause).Err()
	}
	ErrAppendCert = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeAppendCert, "appending certificate error").Wrap(cause).Err()
	}
	ErrConnection = func(cause error) error {
		return jet.NewAppErrBuilder(ErrCodeConnection, "connection error").Wrap(cause).Err()
	}
)

Functions

func BsonDecode

func BsonDecode[T any](payload []byte) (*T, error)

func BsonEncode

func BsonEncode(v interface{}) ([]byte, error)

Types

type Config

type Config struct {
	ConnectionString string
	TimeoutSec       *int
	CertPath         *string
}

type Storage

type Storage struct {
	Instance *mongo.Client
	// contains filtered or unexported fields
}

func Open

func Open(config *Config, logger jet.CLoggerFunc) (*Storage, error)

func (*Storage) Close

func (s *Storage) Close(ctx context.Context)

Jump to

Keyboard shortcuts

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