mongodb

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2024 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalcMongoUri

func CalcMongoUri(params UriParams) string

func TransformId

func TransformId(id string) (primitive.ObjectID, error)

func TransformIds

func TransformIds(ids []string) ([]primitive.ObjectID, error)

Types

type DB

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

func New

func New(uri string, dbName string) (*DB, error)

func (*DB) GetCollection

func (m *DB) GetCollection(n string) *mongo.Collection

type EntityCreator

type EntityCreator[Entity any] func() *Entity

type EntityTransformer

type EntityTransformer[Entity any, Transform any] func(*Entity) Transform

type Helper

type Helper[Entity any, Transform any] interface {
	GetFilterCount(ctx context.Context, filter bson.M, options ...*options.CountOptions) (int64, *i18np.Error)
	GetListFilter(ctx context.Context, filter bson.M, options ...*options.FindOptions) ([]Entity, *i18np.Error)
	GetListFilterTransform(ctx context.Context, filter bson.M, transform EntityTransformer[Entity, Transform], options ...*options.FindOptions) ([]Transform, *i18np.Error)
	GetAggregateListFilter(ctx context.Context, pipeline mongo.Pipeline, options ...*options.AggregateOptions) ([]Entity, *i18np.Error)
	GetAggregateListFilterTransform(ctx context.Context, pipeline mongo.Pipeline, transform EntityTransformer[Entity, Transform], options ...*options.AggregateOptions) ([]Transform, *i18np.Error)
	GetFilter(ctx context.Context, filter bson.M, options ...*options.FindOneOptions) (*Entity, bool, *i18np.Error)
	UpdateOne(ctx context.Context, filter bson.M, setter bson.M, options ...*options.UpdateOptions) *i18np.Error
}

func NewHelper

func NewHelper[Entity any, Transform any](collection *mongo.Collection, creator EntityCreator[Entity]) Helper[Entity, Transform]

type UriParams

type UriParams struct {
	Host  string
	Port  string
	User  string
	Pass  string
	Db    string
	Query string
}

Jump to

Keyboard shortcuts

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