mongo

package
v0.0.0-...-80164ef Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLoggerIsRequired = errors.NewError("SYS", "Logger is required")
	ErrConfigIsRequired = errors.NewError("SYS", "Config is required")
)
View Source
var (
	DuplicateUniqueConstraintErrorCode = errors.ErrorCode("a15da443-001")
)

Functions

func ErrDuplicateUniqueConstraint

func ErrDuplicateUniqueConstraint(cause error) error

Types

type Builder

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

func NewBuilder

func NewBuilder() *Builder

func (*Builder) Build

func (b *Builder) Build() (*MongoDB, error)

func (*Builder) Config

func (b *Builder) Config(config *mongoModel.Config) *Builder

func (*Builder) Logger

func (b *Builder) Logger(logger log.Logger) *Builder

type MongoDB

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

func (*MongoDB) Aggregate

func (m *MongoDB) Aggregate(
	ctx context.Context,
	collectionName mongoModel.Collection,
	pipe mongo.Pipeline,
) (*mongo.Cursor, error)

func (*MongoDB) CollectionIndexes

func (m *MongoDB) CollectionIndexes(ctx context.Context, collection mongoModel.Collection) (map[string]*mongoModel.DBIndex, error)

func (*MongoDB) Count

func (m *MongoDB) Count(
	ctx context.Context,
	collectionName mongoModel.Collection,
	find interface{},
	opt *options.CountOptions,
) (int64, error)

func (*MongoDB) CreateIndex

func (m *MongoDB) CreateIndex(ctx context.Context, index *mongoModel.DBIndex) (string, error)

func (*MongoDB) CreateTextIndex

func (m *MongoDB) CreateTextIndex(ctx context.Context, index *mongoModel.DBTextIndex) (string, error)

func (*MongoDB) DeleteMany

func (m *MongoDB) DeleteMany(
	ctx context.Context,
	collectionName mongoModel.Collection,
	filter interface{},
	opt *options.DeleteOptions,
) (*mongo.DeleteResult, error)

func (*MongoDB) DeleteOne

func (m *MongoDB) DeleteOne(
	ctx context.Context,
	collectionName mongoModel.Collection,
	filter interface{},
	opt *options.DeleteOptions,
) (*mongo.DeleteResult, error)

func (*MongoDB) Find

func (m *MongoDB) Find(
	ctx context.Context,
	collectionName mongoModel.Collection,
	results interface{},
	find interface{},
	opt *options.FindOptions,
) error

func (*MongoDB) FindOne

func (m *MongoDB) FindOne(
	ctx context.Context,
	collectionName mongoModel.Collection,
	resultModel,
	findQuery interface{},
	findOptions *options.FindOneOptions,
) error

func (*MongoDB) FindOneAndUpdate

func (m *MongoDB) FindOneAndUpdate(
	ctx context.Context,
	collectionName mongoModel.Collection,
	resultModel,
	filter,
	updateData interface{},
	opt *options.FindOneAndUpdateOptions,
) error

func (*MongoDB) Insert

func (m *MongoDB) Insert(ctx context.Context, collectionName mongoModel.Collection, data interface{}) (string, error)

func (*MongoDB) InsertMany

func (m *MongoDB) InsertMany(ctx context.Context, collectionName mongoModel.Collection, data []interface{}) ([]string, error)

func (*MongoDB) ReplaceOne

func (m *MongoDB) ReplaceOne(
	ctx context.Context,
	collectionName mongoModel.Collection,
	filter interface{},
	data interface{},
) error

func (*MongoDB) Start

func (m *MongoDB) Start(ctx context.Context) error

func (*MongoDB) Stop

func (m *MongoDB) Stop(ctx context.Context) error

func (*MongoDB) TryCreateIndex

func (m *MongoDB) TryCreateIndex(ctx context.Context, index *mongoModel.DBIndex) error

func (*MongoDB) UpdateMany

func (m *MongoDB) UpdateMany(
	ctx context.Context,
	collectionName mongoModel.Collection,
	filter interface{},
	data interface{},
	opts ...*options.UpdateOptions,
) (int64, error)

func (*MongoDB) UpdateOne

func (m *MongoDB) UpdateOne(
	ctx context.Context,
	collectionName mongoModel.Collection,
	filter,
	data interface{},
	opts ...*options.UpdateOptions,
) (int64, error)

type Repository

type Repository interface {
	Insert(ctx context.Context, collection mongoModel.Collection, data interface{}) (string, error)

	InsertMany(ctx context.Context, collection mongoModel.Collection, data []interface{}) ([]string, error)

	FindOneAndUpdate(
		ctx context.Context,
		collection mongoModel.Collection,
		resultModel,
		filter,
		updateData interface{},
		opt *options.FindOneAndUpdateOptions,
	) error

	ReplaceOne(ctx context.Context, collection mongoModel.Collection, filter, data interface{}) error

	UpdateOne(
		ctx context.Context,
		collection mongoModel.Collection,
		filter,
		data interface{},
		opts ...*options.UpdateOptions,
	) (int64, error)

	UpdateMany(
		ctx context.Context,
		collection mongoModel.Collection,
		filter interface{},
		data interface{},
		opts ...*options.UpdateOptions,
	) (int64, error)

	Find(ctx context.Context, collection mongoModel.Collection, results, find interface{}, opt *options.FindOptions) error

	FindOne(
		ctx context.Context,
		collection mongoModel.Collection,
		resultModel,
		findQuery interface{},
		findOptions *options.FindOneOptions,
	) error

	DeleteOne(ctx context.Context,
		collection mongoModel.Collection,
		filter interface{},
		opt *options.DeleteOptions,
	) (*mongo.DeleteResult, error)

	DeleteMany(ctx context.Context,
		collection mongoModel.Collection,
		filter interface{},
		opt *options.DeleteOptions,
	) (*mongo.DeleteResult, error)

	Count(ctx context.Context, collection mongoModel.Collection, find interface{}, opt *options.CountOptions) (int64, error)

	Aggregate(ctx context.Context, collection mongoModel.Collection, pipe mongo.Pipeline) (*mongo.Cursor, error)

	CreateTextIndex(ctx context.Context, index *mongoModel.DBTextIndex) (string, error)

	CreateIndex(ctx context.Context, index *mongoModel.DBIndex) (string, error)

	TryCreateIndex(ctx context.Context, index *mongoModel.DBIndex) error

	CollectionIndexes(ctx context.Context, collection mongoModel.Collection) (map[string]*mongoModel.DBIndex, error)
}

Directories

Path Synopsis
test

Jump to

Keyboard shortcuts

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