mongo

package module
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MulanPSL-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultNewClient1

func DefaultNewClient1(c *ClientConfig, cc *Config) (es *mongo.Database, err error)

func DefaultNewClient2

func DefaultNewClient2(c *ClientConfig, cc *Config) (es *mongo.Database, err error)

func OperationApiLog added in v0.1.2

func OperationApiLog(c *Client, tbl, op string, args [][2]interface{}) func()

Types

type Client

type Client struct {
	Client *mongo.Database
	Cfg    ClientConfig

	Log          logger.Interface
	CreateClient func(c *ClientConfig, cc *Config) (es *mongo.Database, err error)
	// contains filtered or unexported fields
}

func (*Client) CliFlags

func (c *Client) CliFlags(name string) []cli.Flag

func (*Client) Init

func (c *Client) Init() (err error)

func (*Client) Load

func (c *Client) Load(name string, cfg *Config) (err error)

func (*Client) Ref

func (c *Client) Ref() *Component

type ClientConfig

type ClientConfig struct {
	Host        string `json:"host"          yaml:"host"`
	User        string `json:"user"          yaml:"user"`
	Pwd         string `json:"password"      yaml:"password"`
	DB          string `json:"db"            yaml:"db"`
	DSN         string `json:"dsn"           yaml:"dsn"`
	Options     string `json:"options"       yaml:"options"`
	MinPoolSize int    `json:"min_pool_size" yaml:"min_pool_size"`
	MaxPoolSize int    `json:"max_pool_size" yaml:"max_pool_size"`
}

type Component

type Component struct {
	DSNPrint bool
	Cfg      Config
	Clts     map[string]*Client
}

func (*Component) CliFlags

func (c *Component) CliFlags() []cli.Flag

func (*Component) Close

func (c *Component) Close(_ logger.Interface, _ gsf.Config) error

func (*Component) Init

func (c *Component) Init(log logger.Interface, cfg gsf.Config) (err error)

func (*Component) Run

func (c *Component) Run(_ logger.Interface, _ gsf.Config) (err error)

type Config

type Config struct {
	ReqMaxTime    int `json:"rep_max_time"    yaml:"rep_max_time"`
	MaxIdleTime   int `json:"max_idle_time"   yaml:"max_idle_time"`
	SelectionTime int `json:"selection_time"  yaml:"selection_time"`
	SlowThreshold int `json:"slow_threshold"  yaml:"slow_threshold"`
}

type Operation

type Operation struct {
	ApiLog func(c *Client, tbl, op string, args [][2]interface{}) func()
	// contains filtered or unexported fields
}

func NewOperation

func NewOperation(c *Client) *Operation

func (*Operation) AggregateAll

func (c *Operation) AggregateAll(list interface{}, table string, pipeline interface{}, opts ...*options.AggregateOptions) error

func (*Operation) Count

func (c *Operation) Count(table string, pipeline interface{}, opts ...*options.CountOptions) int64

func (*Operation) FindAll

func (c *Operation) FindAll(list interface{}, table string, filter interface{}, opts ...*options.FindOptions) error

func (*Operation) FindOne

func (c *Operation) FindOne(data interface{}, table string, filter interface{}, opts ...*options.FindOneOptions) error

func (*Operation) Insert

func (c *Operation) Insert(table string, data interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

func (*Operation) Update

func (c *Operation) Update(table string, filter, data interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

Jump to

Keyboard shortcuts

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