mongodb

package
v2.7.19-test Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: Apache-2.0 Imports: 13 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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 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 ...bson.D) (*Store, error)

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 ...bson.D) 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