mongodb

package
v2.24.2 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrPathNotFound = errors.New("path not found")

Functions

func ConvertStringValueToInt64 added in v2.21.0

func ConvertStringValueToInt64(jsonMap any, permitMissingPaths bool, paths ...string) (any, error)

ConvertStringValueToInt64 converts string values to int64 in a JSON map based on provided paths. It iterates over the specified paths in the JSON map and converts the string values found at those paths to int64 values. If permitMissingPaths is set to true, missing paths in the JSON map will be ignored and the modified JSON map will be returned. If permitMissingPaths is set to false, an error will be returned if any of the specified paths are not found in the JSON map. The function returns the updated JSON map with the converted int64 values. If an error occurs during the conversion, the partially modified JSON map is returned along with the error.

func MarshalProtoBSON added in v2.21.0

func MarshalProtoBSON(m proto.Message, update updateJSON) ([]byte, error)

func UnmarshalProtoBSON added in v2.21.0

func UnmarshalProtoBSON(data []byte, m proto.Message, update updateJSON) error

Types

type Config

type Config struct {
	URI             string        `yaml:"uri" json:"uri"`
	Database        string        `yaml:"database" json:"database"`
	MaxPoolSize     uint64        `yaml:"maxPoolSize" json:"maxPoolSize"`
	MaxConnIdleTime time.Duration `yaml:"maxConnIdleTime" json:"maxConnIdleTime"`
	TLS             client.Config `yaml:"tls" json:"tls"`
}

func (*Config) Validate

func (c *Config) Validate() error

type OnClearFn

type OnClearFn = func(context.Context) error

type Operator added in v2.21.0

type Operator = string
const (
	And    Operator = "$and"
	Or     Operator = "$or"
	Exists Operator = "$exists"
	All    Operator = "$all"
	In     Operator = "$in"
	Set    Operator = "$set"
	Unset  Operator = "$unset"
	Match  Operator = "$match"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements an Store for MongoDB.

func NewStore

func NewStore(ctx context.Context, cfg *Config, tls *tls.Config, tracerProvider trace.TracerProvider) (*Store, error)

NewStore creates a new Store.

func NewStoreWithCollection

func NewStoreWithCollection(ctx context.Context, cfg *Config, tls *tls.Config, tracerProvider trace.TracerProvider, collection string, indexes ...mongo.IndexModel) (*Store, error)

func NewStoreWithCollections added in v2.19.1

func NewStoreWithCollections(ctx context.Context, cfg *Config, tls *tls.Config, tracerProvider trace.TracerProvider, collections map[string][]mongo.IndexModel) (*Store, error)

func (*Store) AddCloseFunc added in v2.16.0

func (s *Store) AddCloseFunc(f func())

func (*Store) Clear

func (s *Store) Clear(ctx context.Context) error

Clear clears the event storage.

func (*Store) Client

func (s *Store) Client() *mongo.Client

Get mongodb client

func (*Store) Close

func (s *Store) Close(ctx context.Context) error

Close closes the database session.

func (*Store) Collection

func (s *Store) Collection(collection string) *mongo.Collection

Get collection with given name

func (*Store) DBName

func (s *Store) DBName() string

DBName returns db name

func (*Store) DropCollection

func (s *Store) DropCollection(ctx context.Context, collection string) error

Drops selected collection from database

func (*Store) DropDatabase

func (s *Store) DropDatabase(ctx context.Context) error

Drops the whole database

func (*Store) EnsureIndex

func (s *Store) EnsureIndex(ctx context.Context, collection string, indexes ...mongo.IndexModel) error

func (*Store) SetOnClear

func (s *Store) SetOnClear(onClear OnClearFn)

Set the function called on Clear

Jump to

Keyboard shortcuts

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