mongo

package module
v1.6.3 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: MIT Imports: 6 Imported by: 0

README

mg

go get github.com/gocrud/mg

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetStrId

func GetStrId() string

Types

type Aggregate

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

func (*Aggregate) Count

func (a *Aggregate) Count() (int64, error)

func (*Aggregate) Find

func (a *Aggregate) Find(data any) error

func (*Aggregate) FindOne

func (a *Aggregate) FindOne(data any) error

func (*Aggregate) FindPageList

func (a *Aggregate) FindPageList(pageIndex, pageSize int64, data any) (int64, error)

type Client

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

func NewClient

func NewClient(ctx context.Context, host string) (*Client, error)

func (*Client) NewDB

func (c *Client) NewDB(name string) *DB

func (*Client) Transaction

func (c *Client) Transaction(fn func(sessionContext mongo.SessionContext) error) error

type Collection

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

func (*Collection) Aggregate

func (c *Collection) Aggregate(ctx context.Context, pipes ...bson.D) *Aggregate

func (*Collection) DeleteMany

func (c *Collection) DeleteMany(ctx context.Context, filter bson.M) error

func (*Collection) DeleteOne

func (c *Collection) DeleteOne(ctx context.Context, filter bson.M) error

func (*Collection) Find

func (c *Collection) Find(ctx context.Context, filter bson.M, data any) error

func (*Collection) FindByID

func (c *Collection) FindByID(ctx context.Context, id string, data any) error

func (*Collection) FindByObjID

func (c *Collection) FindByObjID(ctx context.Context, id primitive.ObjectID, data any) error

func (*Collection) FindOne

func (c *Collection) FindOne(ctx context.Context, filter bson.M, data any) error

func (*Collection) InsertMany

func (c *Collection) InsertMany(ctx context.Context, docs []any) error

func (*Collection) InsertOne

func (c *Collection) InsertOne(ctx context.Context, doc any) error

func (*Collection) ReplaceOne

func (c *Collection) ReplaceOne(ctx context.Context, filter bson.M, data any) error

func (*Collection) UpdateMany

func (c *Collection) UpdateMany(ctx context.Context, filter bson.M, data any) error

func (*Collection) UpdateOne

func (c *Collection) UpdateOne(ctx context.Context, filter bson.M, data any) error

type DB

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

func (*DB) Coll

func (d *DB) Coll(name string) *Collection

func (*DB) Model

func (d *DB) Model(coll ICollection) *Collection

type Filter

type Filter struct {
}

type ICollection added in v1.6.2

type ICollection interface {
	CollName() string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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