mongodb

package
v0.0.0-...-d2182b9 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package mongodb is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrCouldNotConnect = func(err error) error {
		return errors.New("could not connect to mongodb, details: " + err.Error())
	}
	ErrCantPing = func(err error) error {
		return errors.New("can't ping mongodb, details: " + err.Error())
	}
	ErrInvalidConnString = func(err error) error {
		return errors.New("invalid connection string, details: " + err.Error())
	}
)

Functions

This section is empty.

Types

type Collection

type Collection interface {
	Name() string
	InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)
	InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)
	DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)
	UpdateByID(ctx context.Context, id interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	UpdateOne(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	UpdateMany(ctx context.Context, filter interface{}, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)
	ReplaceOne(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)
	Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)
	CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)
	EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)
	Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)
	Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (cur *mongo.Cursor, err error)
	FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult
	FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult
	FindOneAndReplace(ctx context.Context, filter interface{}, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult
	FindOneAndUpdate(ctx context.Context, filter interface{}, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult
	Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)
	BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...*options.BulkWriteOptions) (*mongo.BulkWriteResult, error)
	Indexes() mongo.IndexView
	Drop(ctx context.Context) error
}

type Database

type Database interface {
	Name() string
	URI() string
	Collection(name string) Collection
}

func New

func New(opts Options) (db Database, err error)

type MockCollection

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

MockCollection is a mock of Collection interface.

func NewMockCollection

func NewMockCollection(ctrl *gomock.Controller) *MockCollection

NewMockCollection creates a new mock instance.

func (*MockCollection) Aggregate

func (m *MockCollection) Aggregate(ctx context.Context, pipeline interface{}, opts ...*options.AggregateOptions) (*mongo.Cursor, error)

Aggregate mocks base method.

func (*MockCollection) BulkWrite

BulkWrite mocks base method.

func (*MockCollection) CountDocuments

func (m *MockCollection) CountDocuments(ctx context.Context, filter interface{}, opts ...*options.CountOptions) (int64, error)

CountDocuments mocks base method.

func (*MockCollection) DeleteMany

func (m *MockCollection) DeleteMany(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteMany mocks base method.

func (*MockCollection) DeleteOne

func (m *MockCollection) DeleteOne(ctx context.Context, filter interface{}, opts ...*options.DeleteOptions) (*mongo.DeleteResult, error)

DeleteOne mocks base method.

func (*MockCollection) Distinct

func (m *MockCollection) Distinct(ctx context.Context, fieldName string, filter interface{}, opts ...*options.DistinctOptions) ([]interface{}, error)

Distinct mocks base method.

func (*MockCollection) Drop

func (m *MockCollection) Drop(ctx context.Context) error

Drop mocks base method.

func (*MockCollection) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockCollection) EstimatedDocumentCount

func (m *MockCollection) EstimatedDocumentCount(ctx context.Context, opts ...*options.EstimatedDocumentCountOptions) (int64, error)

EstimatedDocumentCount mocks base method.

func (*MockCollection) Find

func (m *MockCollection) Find(ctx context.Context, filter interface{}, opts ...*options.FindOptions) (*mongo.Cursor, error)

Find mocks base method.

func (*MockCollection) FindOne

func (m *MockCollection) FindOne(ctx context.Context, filter interface{}, opts ...*options.FindOneOptions) *mongo.SingleResult

FindOne mocks base method.

func (*MockCollection) FindOneAndDelete

func (m *MockCollection) FindOneAndDelete(ctx context.Context, filter interface{}, opts ...*options.FindOneAndDeleteOptions) *mongo.SingleResult

FindOneAndDelete mocks base method.

func (*MockCollection) FindOneAndReplace

func (m *MockCollection) FindOneAndReplace(ctx context.Context, filter, replacement interface{}, opts ...*options.FindOneAndReplaceOptions) *mongo.SingleResult

FindOneAndReplace mocks base method.

func (*MockCollection) FindOneAndUpdate

func (m *MockCollection) FindOneAndUpdate(ctx context.Context, filter, update interface{}, opts ...*options.FindOneAndUpdateOptions) *mongo.SingleResult

FindOneAndUpdate mocks base method.

func (*MockCollection) Indexes

func (m *MockCollection) Indexes() mongo.IndexView

Indexes mocks base method.

func (*MockCollection) InsertMany

func (m *MockCollection) InsertMany(ctx context.Context, documents []interface{}, opts ...*options.InsertManyOptions) (*mongo.InsertManyResult, error)

InsertMany mocks base method.

func (*MockCollection) InsertOne

func (m *MockCollection) InsertOne(ctx context.Context, document interface{}, opts ...*options.InsertOneOptions) (*mongo.InsertOneResult, error)

InsertOne mocks base method.

func (*MockCollection) Name

func (m *MockCollection) Name() string

Name mocks base method.

func (*MockCollection) ReplaceOne

func (m *MockCollection) ReplaceOne(ctx context.Context, filter, replacement interface{}, opts ...*options.ReplaceOptions) (*mongo.UpdateResult, error)

ReplaceOne mocks base method.

func (*MockCollection) UpdateByID

func (m *MockCollection) UpdateByID(ctx context.Context, id, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateByID mocks base method.

func (*MockCollection) UpdateMany

func (m *MockCollection) UpdateMany(ctx context.Context, filter, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateMany mocks base method.

func (*MockCollection) UpdateOne

func (m *MockCollection) UpdateOne(ctx context.Context, filter, update interface{}, opts ...*options.UpdateOptions) (*mongo.UpdateResult, error)

UpdateOne mocks base method.

func (*MockCollection) Watch

func (m *MockCollection) Watch(ctx context.Context, pipeline interface{}, opts ...*options.ChangeStreamOptions) (*mongo.ChangeStream, error)

Watch mocks base method.

type MockCollectionMockRecorder

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

MockCollectionMockRecorder is the mock recorder for MockCollection.

func (*MockCollectionMockRecorder) Aggregate

func (mr *MockCollectionMockRecorder) Aggregate(ctx, pipeline interface{}, opts ...interface{}) *gomock.Call

Aggregate indicates an expected call of Aggregate.

func (*MockCollectionMockRecorder) BulkWrite

func (mr *MockCollectionMockRecorder) BulkWrite(ctx, models interface{}, opts ...interface{}) *gomock.Call

BulkWrite indicates an expected call of BulkWrite.

func (*MockCollectionMockRecorder) CountDocuments

func (mr *MockCollectionMockRecorder) CountDocuments(ctx, filter interface{}, opts ...interface{}) *gomock.Call

CountDocuments indicates an expected call of CountDocuments.

func (*MockCollectionMockRecorder) DeleteMany

func (mr *MockCollectionMockRecorder) DeleteMany(ctx, filter interface{}, opts ...interface{}) *gomock.Call

DeleteMany indicates an expected call of DeleteMany.

func (*MockCollectionMockRecorder) DeleteOne

func (mr *MockCollectionMockRecorder) DeleteOne(ctx, filter interface{}, opts ...interface{}) *gomock.Call

DeleteOne indicates an expected call of DeleteOne.

func (*MockCollectionMockRecorder) Distinct

func (mr *MockCollectionMockRecorder) Distinct(ctx, fieldName, filter interface{}, opts ...interface{}) *gomock.Call

Distinct indicates an expected call of Distinct.

func (*MockCollectionMockRecorder) Drop

func (mr *MockCollectionMockRecorder) Drop(ctx interface{}) *gomock.Call

Drop indicates an expected call of Drop.

func (*MockCollectionMockRecorder) EstimatedDocumentCount

func (mr *MockCollectionMockRecorder) EstimatedDocumentCount(ctx interface{}, opts ...interface{}) *gomock.Call

EstimatedDocumentCount indicates an expected call of EstimatedDocumentCount.

func (*MockCollectionMockRecorder) Find

func (mr *MockCollectionMockRecorder) Find(ctx, filter interface{}, opts ...interface{}) *gomock.Call

Find indicates an expected call of Find.

func (*MockCollectionMockRecorder) FindOne

func (mr *MockCollectionMockRecorder) FindOne(ctx, filter interface{}, opts ...interface{}) *gomock.Call

FindOne indicates an expected call of FindOne.

func (*MockCollectionMockRecorder) FindOneAndDelete

func (mr *MockCollectionMockRecorder) FindOneAndDelete(ctx, filter interface{}, opts ...interface{}) *gomock.Call

FindOneAndDelete indicates an expected call of FindOneAndDelete.

func (*MockCollectionMockRecorder) FindOneAndReplace

func (mr *MockCollectionMockRecorder) FindOneAndReplace(ctx, filter, replacement interface{}, opts ...interface{}) *gomock.Call

FindOneAndReplace indicates an expected call of FindOneAndReplace.

func (*MockCollectionMockRecorder) FindOneAndUpdate

func (mr *MockCollectionMockRecorder) FindOneAndUpdate(ctx, filter, update interface{}, opts ...interface{}) *gomock.Call

FindOneAndUpdate indicates an expected call of FindOneAndUpdate.

func (*MockCollectionMockRecorder) Indexes

func (mr *MockCollectionMockRecorder) Indexes() *gomock.Call

Indexes indicates an expected call of Indexes.

func (*MockCollectionMockRecorder) InsertMany

func (mr *MockCollectionMockRecorder) InsertMany(ctx, documents interface{}, opts ...interface{}) *gomock.Call

InsertMany indicates an expected call of InsertMany.

func (*MockCollectionMockRecorder) InsertOne

func (mr *MockCollectionMockRecorder) InsertOne(ctx, document interface{}, opts ...interface{}) *gomock.Call

InsertOne indicates an expected call of InsertOne.

func (*MockCollectionMockRecorder) Name

Name indicates an expected call of Name.

func (*MockCollectionMockRecorder) ReplaceOne

func (mr *MockCollectionMockRecorder) ReplaceOne(ctx, filter, replacement interface{}, opts ...interface{}) *gomock.Call

ReplaceOne indicates an expected call of ReplaceOne.

func (*MockCollectionMockRecorder) UpdateByID

func (mr *MockCollectionMockRecorder) UpdateByID(ctx, id, update interface{}, opts ...interface{}) *gomock.Call

UpdateByID indicates an expected call of UpdateByID.

func (*MockCollectionMockRecorder) UpdateMany

func (mr *MockCollectionMockRecorder) UpdateMany(ctx, filter, update interface{}, opts ...interface{}) *gomock.Call

UpdateMany indicates an expected call of UpdateMany.

func (*MockCollectionMockRecorder) UpdateOne

func (mr *MockCollectionMockRecorder) UpdateOne(ctx, filter, update interface{}, opts ...interface{}) *gomock.Call

UpdateOne indicates an expected call of UpdateOne.

func (*MockCollectionMockRecorder) Watch

func (mr *MockCollectionMockRecorder) Watch(ctx, pipeline interface{}, opts ...interface{}) *gomock.Call

Watch indicates an expected call of Watch.

type MockDatabase

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

MockDatabase is a mock of Database interface.

func NewMockDatabase

func NewMockDatabase(ctrl *gomock.Controller) *MockDatabase

NewMockDatabase creates a new mock instance.

func (*MockDatabase) Collection

func (m *MockDatabase) Collection(name string) Collection

Collection mocks base method.

func (*MockDatabase) EXPECT

EXPECT returns an object that allows the caller to indicate expected use.

func (*MockDatabase) Name

func (m *MockDatabase) Name() string

Name mocks base method.

func (*MockDatabase) URI

func (m *MockDatabase) URI() string

URI mocks base method.

type MockDatabaseMockRecorder

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

MockDatabaseMockRecorder is the mock recorder for MockDatabase.

func (*MockDatabaseMockRecorder) Collection

func (mr *MockDatabaseMockRecorder) Collection(name interface{}) *gomock.Call

Collection indicates an expected call of Collection.

func (*MockDatabaseMockRecorder) Name

func (mr *MockDatabaseMockRecorder) Name() *gomock.Call

Name indicates an expected call of Name.

func (*MockDatabaseMockRecorder) URI

URI indicates an expected call of URI.

type Options

type Options struct {
	URI        string
	CtxTimeout time.Duration
	IsReader   bool
}

func (*Options) ExtractConnString

func (o *Options) ExtractConnString() (connstring.ConnString, error)

func (*Options) SetDefaults

func (o *Options) SetDefaults()

Jump to

Keyboard shortcuts

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