mongodb

package
v1.1.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: MIT Imports: 7 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 {
	// contains filtered or unexported fields
}

func GetClient

func GetClient(dbCig *MongoDBConfig, ctx context.Context) (*Client, error)

GetClient ctx, cancel := context.WithTimeout(context.Background(), CONFIG.Timeout*time.Second)

func (*Client) Aggregate

func (c *Client) Aggregate(ctx context.Context, tableName string, groupStage mongo.Pipeline) ([]bson.M, error)

func (*Client) DeleteOne

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

func (*Client) Disconnect

func (c *Client) Disconnect(ctx context.Context) error

func (*Client) Find

func (c *Client) Find(ctx context.Context, tableName string, filters ...interface{}) ([]bson.M, error)

func (*Client) FindOne

func (c *Client) FindOne(ctx context.Context, tableName string, filter interface{}) *mongo.SingleResult

func (*Client) InsertOne

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

func (*Client) Ping

func (c *Client) Ping(ctx context.Context) error

func (*Client) UpdateOne

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

type MongoDBConfig

type MongoDBConfig struct {
	Timeout time.Duration `mapstructure:"timeout" json:"timeout" yaml:"timeout"`
	DB      string        `mapstructure:"db" json:"db" yaml:"db"`
	Addr    string        `mapstructure:"addr" json:"addr" yaml:"addr"`
}

func (*MongoDBConfig) GetApplyURI

func (md *MongoDBConfig) GetApplyURI() string

Jump to

Keyboard shortcuts

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