mongo

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func New

func New(conf Config, logger Logger, metrics Metrics) *Client

func (*Client) CountDocuments

func (c *Client) CountDocuments(ctx context.Context, collection string, filter interface{}) (int64, error)

func (*Client) DeleteMany

func (c *Client) DeleteMany(ctx context.Context, collection string, filter interface{}) (int64, error)

func (*Client) DeleteOne

func (c *Client) DeleteOne(ctx context.Context, collection string, filter interface{}) (int64, error)

func (*Client) Drop

func (c *Client) Drop(ctx context.Context, collection string) error

func (*Client) Find

func (c *Client) Find(ctx context.Context, collection string, filter interface{}, results interface{}) error

func (*Client) FindOne

func (c *Client) FindOne(ctx context.Context, collection string, filter interface{}, result interface{}) error

func (*Client) InsertMany

func (c *Client) InsertMany(ctx context.Context, collection string, documents []interface{}) ([]interface{}, error)

func (*Client) InsertOne

func (c *Client) InsertOne(ctx context.Context, collection string, document interface{}) (interface{}, error)

func (*Client) UpdateByID

func (c *Client) UpdateByID(ctx context.Context, collection string, id interface{}, update interface{}) (int64, error)

func (*Client) UpdateMany

func (c *Client) UpdateMany(ctx context.Context, collection string, filter interface{}, update interface{}) (int64, error)

func (*Client) UpdateOne

func (c *Client) UpdateOne(ctx context.Context, collection string, filter interface{}, update interface{}) error

type Config

type Config interface {
	Get(key string) string
	GetOrDefault(key, def string) string
}

type Logger

type Logger interface {
	Debug(args ...interface{})
	Debugf(pattern string, args ...interface{})
	Log(args ...interface{})
	Logf(pattern string, args ...interface{})
	Error(args ...interface{})
	Errorf(patter string, args ...interface{})
}

type Metrics

type Metrics interface {
	NewCounter(name, desc string)
	NewUpDownCounter(name, desc string)
	NewHistogram(name, desc string, buckets ...float64)
	NewGauge(name, desc string)

	IncrementCounter(ctx context.Context, name string, labels ...string)
	DeltaUpDownCounter(ctx context.Context, name string, value float64, labels ...string)
	RecordHistogram(ctx context.Context, name string, value float64, labels ...string)
	SetGauge(name string, value float64, labels ...string)
}

Jump to

Keyboard shortcuts

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