mongodb

package
v1.2.15-alpha1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CONFIG = MongoDB{
	DB:      "mongo_test",
	Timeout: 10,
	Addr:    "localhost:27017",
}

Functions

func IsExist

func IsExist() bool

IsExist config file is exist

func Recover added in v1.2.0

func Recover() error

Recover

func Remove

func Remove() error

Remove remove config file

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func GetClient

func GetClient() (*Client, error)

GetClient

func (*Client) Aggregate

func (c *Client) Aggregate(name string, groupStage mongo.Pipeline) ([]bson.M, error)

Aggregate

func (*Client) DeleteOne

func (c *Client) DeleteOne(name string, filter interface{}) error

DeleteOne

func (*Client) Disconnect

func (c *Client) Disconnect() error

Disconnect

func (*Client) Find

func (c *Client) Find(name string, filters ...interface{}) ([]bson.M, error)

Find

func (*Client) FindOne

func (c *Client) FindOne(name string, filter interface{}) *mongo.SingleResult

FindOne

func (*Client) InsertOne

func (c *Client) InsertOne(name string, filter interface{}) (interface{}, error)

InsertOne

func (*Client) Ping

func (c *Client) Ping() error

Ping

func (*Client) UpdateOne

func (c *Client) UpdateOne(name string, filter, update interface{}) (*mongo.UpdateResult, error)

UpdateByID

type MongoDB

type MongoDB 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 (*MongoDB) GetApplyURI

func (md *MongoDB) GetApplyURI() string

Jump to

Keyboard shortcuts

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