mongodb

package
v2.0.8 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

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, error)
	GetListFilter(ctx context.Context, filter bson.M, options ...*options.FindOptions) ([]Entity, error)
	GetListFilterTransform(ctx context.Context, filter bson.M, transform EntityTransformer[Entity, Transform], options ...*options.FindOptions) ([]Transform, error)
	GetAggregateListFilter(ctx context.Context, pipeline mongo.Pipeline, options ...*options.AggregateOptions) ([]Entity, error)
	GetAggregateListFilterTransform(ctx context.Context, pipeline mongo.Pipeline, transform EntityTransformer[Entity, Transform], options ...*options.AggregateOptions) ([]Transform, error)
	GetFilter(ctx context.Context, filter bson.M, options ...*options.FindOneOptions) (*Entity, bool, error)
	UpdateOne(ctx context.Context, filter bson.M, setter bson.M, options ...*options.UpdateOptions) 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