mgo

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 5, 2021 License: MIT Imports: 5 Imported by: 0

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
	DB      string
	Timeout time.Duration
}

func Default

func Default() Config

type Repo

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

func (*Repo) Col

func (r *Repo) Col(name string) *mongo.Collection

func (*Repo) ConnectDB

func (r *Repo) ConnectDB(db string) error

func (*Repo) ConnectWithConfig

func (r *Repo) ConnectWithConfig(conf Config) error

func (*Repo) Ctx

func (r *Repo) Ctx() (context.Context, context.CancelFunc)

func (*Repo) Index

func (r *Repo) Index(indexes ...func(context.Context) error) error

func (*Repo) Upsert

func (r *Repo) Upsert(col *mongo.Collection, filter, obj interface{}) Result

type Result

type Result struct {
	Inserted int
	Upserted int
	Err      error
}

func EmptyRes

func EmptyRes() Result

func InsertRes

func InsertRes(ir *mongo.InsertOneResult, err error) Result

func UpsertRes

func UpsertRes(ur *mongo.UpdateResult, err error) Result

func (Result) Empty

func (r Result) Empty() bool

func (Result) Error

func (r Result) Error() bool

func (Result) Ins

func (r Result) Ins() Result

Jump to

Keyboard shortcuts

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