mgom

package
v1.2.4 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2023 License: MIT Imports: 16 Imported by: 4 modules, 17 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetObjectID

func GetObjectID(id interface{}) (primitive.ObjectID, error)

Types

type MgoAggregate

type MgoAggregate interface {
	GetPipeline(q bson.M) mongo.Pipeline
	GetC() string
}

type MgoDBModel

type MgoDBModel interface {
	DisableCheckBeforeSave(b bool)
	SetDB(db *mongo.Database)
	BatchUpdate(doclist []dao.DocInter, getField func(d dao.DocInter) bson.D, u dao.LogUser) (failed []dao.DocInter, err error)
	BatchSave(doclist []dao.DocInter, u dao.LogUser) (inserted []interface{}, failed []dao.DocInter, err error)
	Save(d dao.DocInter, u dao.LogUser) (interface{}, error)
	RemoveAll(d dao.DocInter, q primitive.M, u dao.LogUser) (int64, error)
	RemoveByID(d dao.DocInter, u dao.LogUser) (int64, error)
	UpdateOne(d dao.DocInter, fields bson.D, u dao.LogUser) (int64, error)
	UpdateAll(d dao.DocInter, q bson.M, fields bson.D, u dao.LogUser) (int64, error)
	UnsetFields(d dao.DocInter, q bson.M, fields []string, u dao.LogUser) (int64, error)
	Upsert(d dao.DocInter, u dao.LogUser) (interface{}, error)
	FindByID(d dao.DocInter) error
	FindOne(d dao.DocInter, q bson.M, option ...*options.FindOneOptions) error
	Find(d dao.DocInter, q bson.M, option ...*options.FindOptions) (interface{}, error)
	FindAndExec(
		d dao.DocInter, q bson.M,
		exec func(i interface{}) error,
		opts ...*options.FindOptions,
	) error
	PipeFindOne(aggr MgoAggregate, filter bson.M) error
	PipeFind(aggr MgoAggregate, filter bson.M, opts ...*options.AggregateOptions) (interface{}, error)
	PipeFindAndExec(
		aggr MgoAggregate, q bson.M,
		exec func(i interface{}) error,
		opts ...*options.AggregateOptions,
	) error
	PagePipeFind(aggr MgoAggregate, filter bson.M, sort bson.M, limit, page int64) (interface{}, error)
	PageFind(d dao.DocInter, q bson.M, limit, page int64, opts ...*options.FindOptions) (interface{}, error)
	CountDocuments(d dao.DocInter, q bson.M) (int64, error)
	GetPaginationSource(d dao.DocInter, q bson.M, opts ...*options.FindOptions) util.PaginationSource
	CreateCollection(dlist ...dao.DocInter) error

	//Reference to customer code, use for aggregate pagination
	AggrCountDocuments(aggr MgoAggregate, q bson.M) (int64, error)
	GetPipePaginationSource(aggr MgoAggregate, q bson.M, sort bson.M) util.PaginationSource

	NewFindMgoDS(d dao.DocInter, q bson.M, opts ...*options.FindOptions) MgoDS
	NewPipeFindMgoDS(d MgoAggregate, q bson.M, opts ...*options.AggregateOptions) MgoDS
}

func NewMgoModel

func NewMgoModel(ctx context.Context, db *mongo.Database, log log.Logger) MgoDBModel

func NewMgoModelByReq

func NewMgoModelByReq(req *http.Request, source string) MgoDBModel

type MgoDS added in v0.6.2

type MgoDS interface {
	Exec(exec func(i interface{}) error) error
	ExportCSV(w io.Writer, title []string, exec func(writer *csv.Writer, i interface{}) error) error
}

Jump to

Keyboard shortcuts

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