mongodb

package
v0.0.0-...-9a83fbb Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckInsertError

func CheckInsertError(e error) error

func GetClient

func GetClient(moptions *MongoOptions) (*mongo.Client, error)

func IDFromHex

func IDFromHex(id string) primitive.ObjectID

func IDString

func IDString(id primitive.ObjectID) string

Types

type Collection

type Collection[TEntity any] struct {
	// contains filtered or unexported fields
}

func NewCollection

func NewCollection[TEntity any](c *mongo.Collection) *Collection[TEntity]

func (*Collection[TEntity]) Col

func (c *Collection[TEntity]) Col() *mongo.Collection

func (*Collection[TEntity]) Count

func (c *Collection[TEntity]) Count(ctx context.Context, filter bson.D, opts ...*options.CountOptions) int64

func (*Collection[TEntity]) Delete

func (r *Collection[TEntity]) Delete(ctx context.Context, id primitive.ObjectID) int

func (*Collection[TEntity]) DeleteMany

func (r *Collection[TEntity]) DeleteMany(ctx context.Context, ids []primitive.ObjectID) int

func (*Collection[TEntity]) Exists

func (r *Collection[TEntity]) Exists(ctx context.Context, id primitive.ObjectID) bool

func (*Collection[TEntity]) ExistsByFilter

func (r *Collection[TEntity]) ExistsByFilter(ctx context.Context, filter bson.D) bool

func (*Collection[TEntity]) Find

func (c *Collection[TEntity]) Find(ctx context.Context, filter bson.D, opts ...*options.FindOptions) []TEntity

func (*Collection[TEntity]) FindOne

func (c *Collection[TEntity]) FindOne(ctx context.Context, filter bson.D, opts ...*options.FindOneOptions) *TEntity

func (*Collection[TEntity]) Get

func (r *Collection[TEntity]) Get(ctx context.Context, id primitive.ObjectID) *TEntity

func (*Collection[TEntity]) GetList

func (r *Collection[TEntity]) GetList(ctx context.Context, filter bson.D, page int64, pageSize int64, opt *options.FindOptions) ([]TEntity, int64)

func (*Collection[TEntity]) GetMany

func (r *Collection[TEntity]) GetMany(ctx context.Context, ids []primitive.ObjectID, filter bson.D) []TEntity

func (*Collection[TEntity]) Insert

func (r *Collection[TEntity]) Insert(ctx context.Context, entity *TEntity) primitive.ObjectID

func (*Collection[TEntity]) InsertMany

func (r *Collection[TEntity]) InsertMany(ctx context.Context, entitis []TEntity, ignoreErr bool) []primitive.ObjectID

func (*Collection[TEntity]) UpdateByID

func (r *Collection[TEntity]) UpdateByID(ctx context.Context, id primitive.ObjectID, entity *TEntity) int

func (*Collection[TEntity]) UpdateOne

func (r *Collection[TEntity]) UpdateOne(ctx context.Context, filter bson.D, entity *TEntity, opts ...*options.UpdateOptions) int

type Decimal

type Decimal decimal.Decimal

func (Decimal) DecodeValue

func (d Decimal) DecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error

func (Decimal) EncodeValue

func (d Decimal) EncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error

type MongoOptions

type MongoOptions struct {
	URL    string
	DbName string
}

Jump to

Keyboard shortcuts

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