mongodb

package
v2.22.0 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertStringValueToInt64 added in v2.21.0

func ConvertStringValueToInt64(json map[string]interface{}, path string)

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