mongoex

package
v0.3.68 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCurNil      = errors.New("cur is nil")
	MongoComponent = embedded.NewComponent[*options.ClientOptions]()
	MongoNameMap   = map[string]string{}
)

Functions

func BaseGroup

func BaseGroup[T dependency.IEntity](f func(v ...*T) (int64, error), opt *dependency.BaseOption, p ...*T) (int64, error)

BaseGroup

func CheckLink(ctx context.Context, name, uri string) error

func CoreByCtx

func CoreByCtx(ctx context.Context) *options.ClientOptions

func CoreById

func CoreById(id string) *options.ClientOptions

func GetDbTX

func GetDbTX(id string) contextex.ContextKey

func GetMongoNameByCtx

func GetMongoNameByCtx(ctx context.Context) string

func GetMongoNameByKey

func GetMongoNameByKey(key string) string

func GetNamedMongoClient

func GetNamedMongoClient(key string) *options.ClientOptions

GetNamedMongoClient from mongo map

func Invoke

func Invoke(ctx context.Context, opts *options.ClientOptions, cb func(c *mongo.Client) error) error

func Log

func Log(ctx context.Context, msg string, lvl zapcore.Level)

func NewLoggerOptions

func NewLoggerOptions() *options.LoggerOptions

func NewMongo

func NewMongo(key, dbname, conn string)

func Option2Page

func Option2Page(opt *dependency.BaseOption) *options.FindOptions

Option2Page

func QueryConds

func QueryConds(opt *dependency.BaseOption) bson.D

func QueryFields

func QueryFields(opt *dependency.BaseOption) bson.D

func SetGetKeyFunc

func SetGetKeyFunc(f func(ctx context.Context) string)

Types

type BaseRepository

type BaseRepository[T dependency.IEntity] struct{} // base repository

func (*BaseRepository[T]) BaseCount

func (r *BaseRepository[T]) BaseCount(ctx context.Context, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCount

func (*BaseRepository[T]) BaseCreate

func (r *BaseRepository[T]) BaseCreate(ctx context.Context, ps []*T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseCreate

func (*BaseRepository[T]) BaseDelete

func (r *BaseRepository[T]) BaseDelete(ctx context.Context, p *T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseDelete

func (*BaseRepository[T]) BaseGet

func (r *BaseRepository[T]) BaseGet(ctx context.Context, opts ...dependency.BaseOptionFunc) (*T, error)

BaseGet

func (*BaseRepository[T]) BaseQuery

func (r *BaseRepository[T]) BaseQuery(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, error)

BaseQuery

func (*BaseRepository[T]) BaseQueryWithCount

func (r *BaseRepository[T]) BaseQueryWithCount(ctx context.Context, opts ...dependency.BaseOptionFunc) ([]T, int64, error)

BaseQueryWithCount

func (*BaseRepository[T]) BaseSave

func (r *BaseRepository[T]) BaseSave(ctx context.Context, ps []*T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseSave

func (*BaseRepository[T]) BaseUpdate

func (r *BaseRepository[T]) BaseUpdate(ctx context.Context, p *T, opts ...dependency.BaseOptionFunc) (int64, error)

BaseUpdate

func (*BaseRepository[T]) BuildConds

func (r *BaseRepository[T]) BuildConds(ctx context.Context, t *T, opt *dependency.BaseOption, dbcallback func(*mongo.Database) error) error

BuildConds

func (*BaseRepository[T]) BuildFrmOption

func (r *BaseRepository[T]) BuildFrmOption(ctx context.Context, t *T, opt *dependency.BaseOption, colcallback func(*mongo.Collection) error) error

BuildFrmOption

func (*BaseRepository[T]) BuildFrmOptions

func (r *BaseRepository[T]) BuildFrmOptions(ctx context.Context, t *T, colcallback func(*mongo.Collection) error, opts ...dependency.BaseOptionFunc) error

BuildFrmOptions

type Logger

type Logger struct{}

func NewLogger

func NewLogger() *Logger

func (*Logger) Error

func (l *Logger) Error(err error, message string, _ ...interface{})

func (*Logger) Info

func (l *Logger) Info(_ int, message string, _ ...interface{})

Jump to

Keyboard shortcuts

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