repo

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(uri, db string, maxPool uint64) (*mongo.Database, error)

Types

type BaseRepository

type BaseRepository struct {
	CollectionName string
	DB             *mongo.Database
}

func (*BaseRepository) Aggregate

func (b *BaseRepository) Aggregate(ctx context.Context, sortFields []string, sortValue []int, page int64, limit int64, agg ...interface{}) ([]interface{}, int64, error)

func (*BaseRepository) Collection

func (b *BaseRepository) Collection() *mongo.Collection

func (*BaseRepository) Create

func (b *BaseRepository) Create(ctx context.Context, model interface{}) (primitive.ObjectID, error)

func (*BaseRepository) CreateCompoundIndex

func (b *BaseRepository) CreateCompoundIndex(ctx context.Context, compoundIndex []string, unique bool) error

func (*BaseRepository) CreateMany

func (b *BaseRepository) CreateMany(ctx context.Context, models []interface{}) ([]primitive.ObjectID, error)

func (*BaseRepository) Database

func (b *BaseRepository) Database() *mongo.Database

func (*BaseRepository) Delete

func (b *BaseRepository) Delete(ctx context.Context, ids []primitive.ObjectID) error

func (*BaseRepository) Filter

func (b *BaseRepository) Filter(ctx context.Context, filters map[string]interface{}, sortFields []string, sortValue []int, page int64, limit int64, result interface{}) (int64, error)

func (*BaseRepository) FindById

func (b *BaseRepository) FindById(ctx context.Context, id primitive.ObjectID, value interface{}) error

func (*BaseRepository) FindOne

func (b *BaseRepository) FindOne(ctx context.Context, filters map[string]interface{}, value interface{}) error

func (*BaseRepository) Update

func (b *BaseRepository) Update(ctx context.Context, model interface{}, id primitive.ObjectID, dateModified int64) error

func (*BaseRepository) WithTransaction

func (b *BaseRepository) WithTransaction(ctx context.Context, callback func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*options.TransactionOptions) (interface{}, error)

type Repository

type Repository interface {
	Database() *mongo.Database
	Collection() *mongo.Collection
	FindById(ctx context.Context, id primitive.ObjectID, value interface{}) error
	Create(ctx context.Context, model interface{}) (primitive.ObjectID, error)
	CreateMany(ctx context.Context, models []interface{}) ([]primitive.ObjectID, error)
	Update(ctx context.Context, model interface{}, id primitive.ObjectID, dateModified int64) error
	Delete(ctx context.Context, id []primitive.ObjectID) error
	Filter(ctx context.Context, filters map[string]interface{}, sortFields []string, sortValues []int, page int64, limit int64, result interface{}) (int64, error)
	CreateCompoundIndex(ctx context.Context, compoundIndex []string, unique bool) error
	FindOne(ctx context.Context, filters map[string]interface{}, value interface{}) error
	Aggregate(ctx context.Context, sortFields []string, sortValues []int, page int64, limit int64, agg ...interface{}) ([]interface{}, int64, error)
	WithTransaction(ctx context.Context, fn func(sessCtx mongo.SessionContext) (interface{}, error), opts ...*options.TransactionOptions) (interface{}, error)
}

Jump to

Keyboard shortcuts

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