db

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultDatabase string
)

Functions

This section is empty.

Types

type MongoDB

type MongoDB struct {
	Database      string
	Collection    string
	Filter        map[string]interface{}
	CountPipeline []bson.M // AggregateByPage
	Pipeline      []bson.M // Aggregate/AggregateByPage
}

func (*MongoDB) Aggregate

func (m *MongoDB) Aggregate(ctx context.Context, result interface{}, opts ...*options.AggregateOptions) error

func (*MongoDB) AggregateByPage

func (m *MongoDB) AggregateByPage(ctx context.Context, countResult, result interface{}, opts ...*options.AggregateOptions) error

func (*MongoDB) CountDocuments

func (m *MongoDB) CountDocuments(ctx context.Context) (int64, error)

func (*MongoDB) DeleteById

func (m *MongoDB) DeleteById(ctx context.Context, id interface{}) error

func (*MongoDB) DeleteMany

func (m *MongoDB) DeleteMany(ctx context.Context) (int64, error)

func (*MongoDB) DeleteOne

func (m *MongoDB) DeleteOne(ctx context.Context) (int64, error)

func (*MongoDB) EstimatedDocumentCount

func (m *MongoDB) EstimatedDocumentCount(ctx context.Context) (int64, error)

func (*MongoDB) Find

func (m *MongoDB) Find(ctx context.Context, result interface{}, sortFields ...string) error

func (*MongoDB) FindByPage

func (m *MongoDB) FindByPage(ctx context.Context, paging *Paging, result interface{}, sortFields ...string) (err error)

func (*MongoDB) FindOne

func (m *MongoDB) FindOne(ctx context.Context, result interface{}, sortFields ...string) error

func (*MongoDB) InsertMany

func (m *MongoDB) InsertMany(ctx context.Context, documents []interface{}) ([]interface{}, error)

func (*MongoDB) InsertOne

func (m *MongoDB) InsertOne(ctx context.Context, document interface{}) (interface{}, error)

func (*MongoDB) UpdateById

func (m *MongoDB) UpdateById(ctx context.Context, id, update interface{}, opts ...*options.UpdateOptions) error

func (*MongoDB) UpdateMany

func (m *MongoDB) UpdateMany(ctx context.Context, update interface{}, opts ...*options.UpdateOptions) error

func (*MongoDB) UpdateOne

func (m *MongoDB) UpdateOne(ctx context.Context, update interface{}, opts ...*options.UpdateOptions) error

type Paging

type Paging struct {
	Page      int64 // 当前页
	PageSize  int64 // 每页条数
	Total     int64 // 总条数
	PageCount int64 // 总页数
	StartNums int64 // 起始条数
	EndNums   int64 // 结束条数
}

func (*Paging) GetPages

func (p *Paging) GetPages() *Paging

获取分页信息

Jump to

Keyboard shortcuts

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