gomongo

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const NotFoundDocumentError = "mongo: no documents in result"

Variables

This section is empty.

Functions

func ConnectToMongo

func ConnectToMongo(uri string) *mongo.Client

func InTransactionSession

func InTransactionSession[T any](ctx context.Context, client *mongo.Client, f TransactionFunction[T]) (T, error)

func Int64Ptr

func Int64Ptr(v *int) *int64

func LocationParametersToMongoQuery

func LocationParametersToMongoQuery(parameters *location.LocationParameters) bson.M

func ObjIdListToStrList

func ObjIdListToStrList(list []primitive.ObjectID) []string

func ObjIdToStr

func ObjIdToStr(id *primitive.ObjectID) *string

func StrListToObjIdList

func StrListToObjIdList(list []string) []primitive.ObjectID

func StrToObjId

func StrToObjId(id *string) *primitive.ObjectID

Types

type BaseMongoRepository

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

func NewBaseMongoRepository added in v0.0.2

func NewBaseMongoRepository(database *mongo.Database, collectionName string) *BaseMongoRepository

func (*BaseMongoRepository) Collection

func (m *BaseMongoRepository) Collection() *mongo.Collection

func (*BaseMongoRepository) DeleteOne

func (m *BaseMongoRepository) DeleteOne(ctx context.Context, q bson.M) error

func (*BaseMongoRepository) GetList

func (m *BaseMongoRepository) GetList(ctx context.Context, result interface{}, q bson.M, skip, limit *int, sort *bson.D) (int, error)

func (*BaseMongoRepository) InsertOne

func (m *BaseMongoRepository) InsertOne(ctx context.Context, newValue interface{}) (*primitive.ObjectID, error)

func (*BaseMongoRepository) UpdateOne

func (m *BaseMongoRepository) UpdateOne(ctx context.Context, q bson.M, update bson.M) error

type TransactionFunction added in v0.0.7

type TransactionFunction[T any] func(sc mongo.SessionContext) (T, error)

type Void added in v0.0.7

type Void struct{}

Jump to

Keyboard shortcuts

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