mon

package
v1.13.7 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package mon is a generated GoMock package.

Package mon is a generated GoMock package.

Package mon is a generated GoMock package.

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = mongo.ErrNoDocuments

ErrNotFound is an alias of mongo.ErrNoDocuments

Functions

func DisableInfoLog

func DisableInfoLog()

DisableInfoLog disables info logging of mongo commands, but keeps slow logs.

func DisableLog

func DisableLog()

DisableLog disables logging of mongo commands, includes info and slow logs.

func FormatAddr

func FormatAddr(hosts []string) string

FormatAddr formats mongo hosts to a string.

func Inject

func Inject(key string, client *mongo.Client)

Inject injects a *mongo.Client into the client manager. Typically, this is used to inject a *mongo.Client for test purpose.

func SetSlowThreshold

func SetSlowThreshold(threshold time.Duration)

SetSlowThreshold sets the slow threshold.

Types

type BulkInserter

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

A BulkInserter is used to insert bulk of mongo records.

func NewBulkInserter

func NewBulkInserter(coll Collection, interval ...time.Duration) (*BulkInserter, error)

NewBulkInserter returns a BulkInserter.

func (*BulkInserter) Flush

func (bi *BulkInserter) Flush()

Flush flushes the inserter, writes all pending records.

func (*BulkInserter) Insert

func (bi *BulkInserter) Insert(doc any)

Insert inserts doc.

func (*BulkInserter) SetResultHandler

func (bi *BulkInserter) SetResultHandler(handler ResultHandler)

SetResultHandler sets the result handler.

type ClosableClient

type ClosableClient struct {
	*mongo.Client
}

ClosableClient wraps *mongo.Client and provides a Close method.

func (*ClosableClient) Close

func (cs *ClosableClient) Close() error

Close disconnects the underlying *mongo.Client.

type Collection

type Collection interface {
	// Aggregate executes an aggregation pipeline.
	Aggregate(ctx context.Context, pipeline any, opts ...options.Lister[options.AggregateOptions]) (
		*mongo.Cursor, error)
	// BulkWrite performs a bulk write operation.
	BulkWrite(ctx context.Context, models []mongo.WriteModel, opts ...options.Lister[options.BulkWriteOptions]) (
		*mongo.BulkWriteResult, error)
	// Clone creates a copy of this collection with the same settings.
	Clone(opts ...options.Lister[options.CollectionOptions]) *mongo.Collection
	// CountDocuments returns the number of documents in the collection that match the filter.
	CountDocuments(ctx context.Context, filter any, opts ...options.Lister[options.CountOptions]) (int64, error)
	// Database returns the database that this collection is a part of.
	Database() *mongo.Database
	// DeleteMany deletes documents from the collection that match the filter.
	DeleteMany(ctx context.Context, filter any, opts ...options.Lister[options.DeleteManyOptions]) (
		*mongo.DeleteResult, error)
	// DeleteOne deletes at most one document from the collection that matches the filter.
	DeleteOne(ctx context.Context, filter any, opts ...options.Lister[options.DeleteOneOptions]) (
		*mongo.DeleteResult, error)
	// Distinct returns a list of distinct values for the given key across the collection.
	Distinct(ctx context.Context, fieldName string, filter any,
		opts ...options.Lister[options.DistinctOptions]) (*mongo.DistinctResult, error)
	// Drop drops this collection from database.
	Drop(ctx context.Context, opts ...options.Lister[options.DropCollectionOptions]) error
	// EstimatedDocumentCount returns an estimate of the count of documents in a collection
	// using collection metadata.
	EstimatedDocumentCount(ctx context.Context, opts ...options.Lister[options.EstimatedDocumentCountOptions]) (int64, error)
	// Find finds the documents matching the provided filter.
	Find(ctx context.Context, filter any, opts ...options.Lister[options.FindOptions]) (*mongo.Cursor, error)
	// FindOne returns up to one document that matches the provided filter.
	FindOne(ctx context.Context, filter any, opts ...options.Lister[options.FindOneOptions]) (
		*mongo.SingleResult, error)
	// FindOneAndDelete returns at most one document that matches the filter. If the filter
	// matches multiple documents, only the first document is deleted.
	FindOneAndDelete(ctx context.Context, filter any, opts ...options.Lister[options.FindOneAndDeleteOptions]) (
		*mongo.SingleResult, error)
	// FindOneAndReplace returns at most one document that matches the filter. If the filter
	// matches multiple documents, FindOneAndReplace returns the first document in the
	// collection that matches the filter.
	FindOneAndReplace(ctx context.Context, filter, replacement any,
		opts ...options.Lister[options.FindOneAndReplaceOptions]) (*mongo.SingleResult, error)
	// FindOneAndUpdate returns at most one document that matches the filter. If the filter
	// matches multiple documents, FindOneAndUpdate returns the first document in the
	// collection that matches the filter.
	FindOneAndUpdate(ctx context.Context, filter, update any,
		opts ...options.Lister[options.FindOneAndUpdateOptions]) (*mongo.SingleResult, error)
	// Indexes returns the index view for this collection.
	Indexes() mongo.IndexView
	// InsertMany inserts the provided documents.
	InsertMany(ctx context.Context, documents []any, opts ...options.Lister[options.InsertManyOptions]) (
		*mongo.InsertManyResult, error)
	// InsertOne inserts the provided document.
	InsertOne(ctx context.Context, document any, opts ...options.Lister[options.InsertOneOptions]) (
		*mongo.InsertOneResult, error)
	// ReplaceOne replaces at most one document that matches the filter.
	ReplaceOne(ctx context.Context, filter, replacement any,
		opts ...options.Lister[options.ReplaceOptions]) (*mongo.UpdateResult, error)
	// UpdateByID updates a single document matching the provided filter.
	UpdateByID(ctx context.Context, id, update any,
		opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)
	// UpdateMany updates the provided documents.
	UpdateMany(ctx context.Context, filter, update any,
		opts ...options.Lister[options.UpdateManyOptions]) (*mongo.UpdateResult, error)
	// UpdateOne updates a single document matching the provided filter.
	UpdateOne(ctx context.Context, filter, update any,
		opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)
	// Watch returns a change stream cursor used to receive notifications of changes to the collection.
	Watch(ctx context.Context, pipeline any, opts ...options.Lister[options.ChangeStreamOptions]) (
		*mongo.ChangeStream, error)
}

Collection defines a MongoDB collection.

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 any, opts ...options.Lister[options.AggregateOptions]) (*mongo.Cursor, error)

Aggregate mocks base method.

func (*MockCollection) BulkWrite

BulkWrite mocks base method.

func (*MockCollection) Clone

Clone mocks base method.

func (*MockCollection) CountDocuments

func (m *MockCollection) CountDocuments(ctx context.Context, filter any, opts ...options.Lister[options.CountOptions]) (int64, error)

CountDocuments mocks base method.

func (*MockCollection) Database

func (m *MockCollection) Database() *mongo.Database

Database mocks base method.

func (*MockCollection) DeleteMany

func (m *MockCollection) DeleteMany(ctx context.Context, filter any, opts ...options.Lister[options.DeleteManyOptions]) (*mongo.DeleteResult, error)

DeleteMany mocks base method.

func (*MockCollection) DeleteOne

DeleteOne mocks base method.

func (*MockCollection) Distinct

func (m *MockCollection) Distinct(ctx context.Context, fieldName string, filter any, opts ...options.Lister[options.DistinctOptions]) (*mongo.DistinctResult, error)

Distinct mocks base method.

func (*MockCollection) Drop

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.Lister[options.EstimatedDocumentCountOptions]) (int64, error)

EstimatedDocumentCount mocks base method.

func (*MockCollection) Find

func (m *MockCollection) Find(ctx context.Context, filter any, opts ...options.Lister[options.FindOptions]) (*mongo.Cursor, error)

Find mocks base method.

func (*MockCollection) FindOne

FindOne mocks base method.

func (*MockCollection) FindOneAndDelete

func (m *MockCollection) FindOneAndDelete(ctx context.Context, filter any, opts ...options.Lister[options.FindOneAndDeleteOptions]) (*mongo.SingleResult, error)

FindOneAndDelete mocks base method.

func (*MockCollection) FindOneAndReplace

func (m *MockCollection) FindOneAndReplace(ctx context.Context, filter, replacement any, opts ...options.Lister[options.FindOneAndReplaceOptions]) (*mongo.SingleResult, error)

FindOneAndReplace mocks base method.

func (*MockCollection) FindOneAndUpdate

func (m *MockCollection) FindOneAndUpdate(ctx context.Context, filter, update any, opts ...options.Lister[options.FindOneAndUpdateOptions]) (*mongo.SingleResult, error)

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 []any, opts ...options.Lister[options.InsertManyOptions]) (*mongo.InsertManyResult, error)

InsertMany mocks base method.

func (*MockCollection) InsertOne

InsertOne mocks base method.

func (*MockCollection) ReplaceOne

func (m *MockCollection) ReplaceOne(ctx context.Context, filter, replacement any, opts ...options.Lister[options.ReplaceOptions]) (*mongo.UpdateResult, error)

ReplaceOne mocks base method.

func (*MockCollection) UpdateByID

func (m *MockCollection) UpdateByID(ctx context.Context, id, update any, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)

UpdateByID mocks base method.

func (*MockCollection) UpdateMany

func (m *MockCollection) UpdateMany(ctx context.Context, filter, update any, opts ...options.Lister[options.UpdateManyOptions]) (*mongo.UpdateResult, error)

UpdateMany mocks base method.

func (*MockCollection) UpdateOne

func (m *MockCollection) UpdateOne(ctx context.Context, filter, update any, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)

UpdateOne mocks base method.

func (*MockCollection) Watch

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 any, opts ...any) *gomock.Call

Aggregate indicates an expected call of Aggregate.

func (*MockCollectionMockRecorder) BulkWrite

func (mr *MockCollectionMockRecorder) BulkWrite(ctx, models any, opts ...any) *gomock.Call

BulkWrite indicates an expected call of BulkWrite.

func (*MockCollectionMockRecorder) Clone

func (mr *MockCollectionMockRecorder) Clone(opts ...any) *gomock.Call

Clone indicates an expected call of Clone.

func (*MockCollectionMockRecorder) CountDocuments

func (mr *MockCollectionMockRecorder) CountDocuments(ctx, filter any, opts ...any) *gomock.Call

CountDocuments indicates an expected call of CountDocuments.

func (*MockCollectionMockRecorder) Database

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

Database indicates an expected call of Database.

func (*MockCollectionMockRecorder) DeleteMany

func (mr *MockCollectionMockRecorder) DeleteMany(ctx, filter any, opts ...any) *gomock.Call

DeleteMany indicates an expected call of DeleteMany.

func (*MockCollectionMockRecorder) DeleteOne

func (mr *MockCollectionMockRecorder) DeleteOne(ctx, filter any, opts ...any) *gomock.Call

DeleteOne indicates an expected call of DeleteOne.

func (*MockCollectionMockRecorder) Distinct

func (mr *MockCollectionMockRecorder) Distinct(ctx, fieldName, filter any, opts ...any) *gomock.Call

Distinct indicates an expected call of Distinct.

func (*MockCollectionMockRecorder) Drop

func (mr *MockCollectionMockRecorder) Drop(ctx any, opts ...any) *gomock.Call

Drop indicates an expected call of Drop.

func (*MockCollectionMockRecorder) EstimatedDocumentCount

func (mr *MockCollectionMockRecorder) EstimatedDocumentCount(ctx any, opts ...any) *gomock.Call

EstimatedDocumentCount indicates an expected call of EstimatedDocumentCount.

func (*MockCollectionMockRecorder) Find

func (mr *MockCollectionMockRecorder) Find(ctx, filter any, opts ...any) *gomock.Call

Find indicates an expected call of Find.

func (*MockCollectionMockRecorder) FindOne

func (mr *MockCollectionMockRecorder) FindOne(ctx, filter any, opts ...any) *gomock.Call

FindOne indicates an expected call of FindOne.

func (*MockCollectionMockRecorder) FindOneAndDelete

func (mr *MockCollectionMockRecorder) FindOneAndDelete(ctx, filter any, opts ...any) *gomock.Call

FindOneAndDelete indicates an expected call of FindOneAndDelete.

func (*MockCollectionMockRecorder) FindOneAndReplace

func (mr *MockCollectionMockRecorder) FindOneAndReplace(ctx, filter, replacement any, opts ...any) *gomock.Call

FindOneAndReplace indicates an expected call of FindOneAndReplace.

func (*MockCollectionMockRecorder) FindOneAndUpdate

func (mr *MockCollectionMockRecorder) FindOneAndUpdate(ctx, filter, update any, opts ...any) *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 any, opts ...any) *gomock.Call

InsertMany indicates an expected call of InsertMany.

func (*MockCollectionMockRecorder) InsertOne

func (mr *MockCollectionMockRecorder) InsertOne(ctx, document any, opts ...any) *gomock.Call

InsertOne indicates an expected call of InsertOne.

func (*MockCollectionMockRecorder) ReplaceOne

func (mr *MockCollectionMockRecorder) ReplaceOne(ctx, filter, replacement any, opts ...any) *gomock.Call

ReplaceOne indicates an expected call of ReplaceOne.

func (*MockCollectionMockRecorder) UpdateByID

func (mr *MockCollectionMockRecorder) UpdateByID(ctx, id, update any, opts ...any) *gomock.Call

UpdateByID indicates an expected call of UpdateByID.

func (*MockCollectionMockRecorder) UpdateMany

func (mr *MockCollectionMockRecorder) UpdateMany(ctx, filter, update any, opts ...any) *gomock.Call

UpdateMany indicates an expected call of UpdateMany.

func (*MockCollectionMockRecorder) UpdateOne

func (mr *MockCollectionMockRecorder) UpdateOne(ctx, filter, update any, opts ...any) *gomock.Call

UpdateOne indicates an expected call of UpdateOne.

func (*MockCollectionMockRecorder) Watch

func (mr *MockCollectionMockRecorder) Watch(ctx, pipeline any, opts ...any) *gomock.Call

Watch indicates an expected call of Watch.

type MockcollectionInserter

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

MockcollectionInserter is a mock of collectionInserter interface.

func NewMockcollectionInserter

func NewMockcollectionInserter(ctrl *gomock.Controller) *MockcollectionInserter

NewMockcollectionInserter creates a new mock instance.

func (*MockcollectionInserter) EXPECT

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

func (*MockcollectionInserter) InsertMany

InsertMany mocks base method.

type MockcollectionInserterMockRecorder

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

MockcollectionInserterMockRecorder is the mock recorder for MockcollectionInserter.

func (*MockcollectionInserterMockRecorder) InsertMany

func (mr *MockcollectionInserterMockRecorder) InsertMany(ctx, documents any, opts ...any) *gomock.Call

InsertMany indicates an expected call of InsertMany.

type MockmonClient

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

MockmonClient is a mock of monClient interface.

func NewMockmonClient

func NewMockmonClient(ctrl *gomock.Controller) *MockmonClient

NewMockmonClient creates a new mock instance.

func (*MockmonClient) EXPECT

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

func (*MockmonClient) StartSession

func (m *MockmonClient) StartSession(opts ...options.Lister[options.SessionOptions]) (monSession, error)

StartSession mocks base method.

type MockmonClientMockRecorder

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

MockmonClientMockRecorder is the mock recorder for MockmonClient.

func (*MockmonClientMockRecorder) StartSession

func (mr *MockmonClientMockRecorder) StartSession(opts ...any) *gomock.Call

StartSession indicates an expected call of StartSession.

type MockmonCollection

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

MockmonCollection is a mock of monCollection interface.

func NewMockmonCollection

func NewMockmonCollection(ctrl *gomock.Controller) *MockmonCollection

NewMockmonCollection creates a new mock instance.

func (*MockmonCollection) Aggregate

func (m *MockmonCollection) Aggregate(ctx context.Context, pipeline any, opts ...options.Lister[options.AggregateOptions]) (*mongo.Cursor, error)

Aggregate mocks base method.

func (*MockmonCollection) BulkWrite

BulkWrite mocks base method.

func (*MockmonCollection) Clone

Clone mocks base method.

func (*MockmonCollection) CountDocuments

func (m *MockmonCollection) CountDocuments(ctx context.Context, filter any, opts ...options.Lister[options.CountOptions]) (int64, error)

CountDocuments mocks base method.

func (*MockmonCollection) Database

func (m *MockmonCollection) Database() *mongo.Database

Database mocks base method.

func (*MockmonCollection) DeleteMany

DeleteMany mocks base method.

func (*MockmonCollection) DeleteOne

DeleteOne mocks base method.

func (*MockmonCollection) Distinct

func (m *MockmonCollection) Distinct(ctx context.Context, fieldName string, filter any, opts ...options.Lister[options.DistinctOptions]) *mongo.DistinctResult

Distinct mocks base method.

func (*MockmonCollection) Drop

Drop mocks base method.

func (*MockmonCollection) EXPECT

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

func (*MockmonCollection) EstimatedDocumentCount

func (m *MockmonCollection) EstimatedDocumentCount(ctx context.Context, opts ...options.Lister[options.EstimatedDocumentCountOptions]) (int64, error)

EstimatedDocumentCount mocks base method.

func (*MockmonCollection) Find

func (m *MockmonCollection) Find(ctx context.Context, filter any, opts ...options.Lister[options.FindOptions]) (*mongo.Cursor, error)

Find mocks base method.

func (*MockmonCollection) FindOne

FindOne mocks base method.

func (*MockmonCollection) FindOneAndDelete

FindOneAndDelete mocks base method.

func (*MockmonCollection) FindOneAndReplace

func (m *MockmonCollection) FindOneAndReplace(ctx context.Context, filter, replacement any, opts ...options.Lister[options.FindOneAndReplaceOptions]) *mongo.SingleResult

FindOneAndReplace mocks base method.

func (*MockmonCollection) FindOneAndUpdate

func (m *MockmonCollection) FindOneAndUpdate(ctx context.Context, filter, update any, opts ...options.Lister[options.FindOneAndUpdateOptions]) *mongo.SingleResult

FindOneAndUpdate mocks base method.

func (*MockmonCollection) Indexes

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

Indexes mocks base method.

func (*MockmonCollection) InsertMany

InsertMany mocks base method.

func (*MockmonCollection) InsertOne

InsertOne mocks base method.

func (*MockmonCollection) ReplaceOne

func (m *MockmonCollection) ReplaceOne(ctx context.Context, filter, replacement any, opts ...options.Lister[options.ReplaceOptions]) (*mongo.UpdateResult, error)

ReplaceOne mocks base method.

func (*MockmonCollection) UpdateByID

func (m *MockmonCollection) UpdateByID(ctx context.Context, id, update any, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)

UpdateByID mocks base method.

func (*MockmonCollection) UpdateMany

func (m *MockmonCollection) UpdateMany(ctx context.Context, filter, update any, opts ...options.Lister[options.UpdateManyOptions]) (*mongo.UpdateResult, error)

UpdateMany mocks base method.

func (*MockmonCollection) UpdateOne

func (m *MockmonCollection) UpdateOne(ctx context.Context, filter, update any, opts ...options.Lister[options.UpdateOneOptions]) (*mongo.UpdateResult, error)

UpdateOne mocks base method.

func (*MockmonCollection) Watch

Watch mocks base method.

type MockmonCollectionMockRecorder

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

MockmonCollectionMockRecorder is the mock recorder for MockmonCollection.

func (*MockmonCollectionMockRecorder) Aggregate

func (mr *MockmonCollectionMockRecorder) Aggregate(ctx, pipeline any, opts ...any) *gomock.Call

Aggregate indicates an expected call of Aggregate.

func (*MockmonCollectionMockRecorder) BulkWrite

func (mr *MockmonCollectionMockRecorder) BulkWrite(ctx, models any, opts ...any) *gomock.Call

BulkWrite indicates an expected call of BulkWrite.

func (*MockmonCollectionMockRecorder) Clone

func (mr *MockmonCollectionMockRecorder) Clone(opts ...any) *gomock.Call

Clone indicates an expected call of Clone.

func (*MockmonCollectionMockRecorder) CountDocuments

func (mr *MockmonCollectionMockRecorder) CountDocuments(ctx, filter any, opts ...any) *gomock.Call

CountDocuments indicates an expected call of CountDocuments.

func (*MockmonCollectionMockRecorder) Database

func (mr *MockmonCollectionMockRecorder) Database() *gomock.Call

Database indicates an expected call of Database.

func (*MockmonCollectionMockRecorder) DeleteMany

func (mr *MockmonCollectionMockRecorder) DeleteMany(ctx, filter any, opts ...any) *gomock.Call

DeleteMany indicates an expected call of DeleteMany.

func (*MockmonCollectionMockRecorder) DeleteOne

func (mr *MockmonCollectionMockRecorder) DeleteOne(ctx, filter any, opts ...any) *gomock.Call

DeleteOne indicates an expected call of DeleteOne.

func (*MockmonCollectionMockRecorder) Distinct

func (mr *MockmonCollectionMockRecorder) Distinct(ctx, fieldName, filter any, opts ...any) *gomock.Call

Distinct indicates an expected call of Distinct.

func (*MockmonCollectionMockRecorder) Drop

func (mr *MockmonCollectionMockRecorder) Drop(ctx any, opts ...any) *gomock.Call

Drop indicates an expected call of Drop.

func (*MockmonCollectionMockRecorder) EstimatedDocumentCount

func (mr *MockmonCollectionMockRecorder) EstimatedDocumentCount(ctx any, opts ...any) *gomock.Call

EstimatedDocumentCount indicates an expected call of EstimatedDocumentCount.

func (*MockmonCollectionMockRecorder) Find

func (mr *MockmonCollectionMockRecorder) Find(ctx, filter any, opts ...any) *gomock.Call

Find indicates an expected call of Find.

func (*MockmonCollectionMockRecorder) FindOne

func (mr *MockmonCollectionMockRecorder) FindOne(ctx, filter any, opts ...any) *gomock.Call

FindOne indicates an expected call of FindOne.

func (*MockmonCollectionMockRecorder) FindOneAndDelete

func (mr *MockmonCollectionMockRecorder) FindOneAndDelete(ctx, filter any, opts ...any) *gomock.Call

FindOneAndDelete indicates an expected call of FindOneAndDelete.

func (*MockmonCollectionMockRecorder) FindOneAndReplace

func (mr *MockmonCollectionMockRecorder) FindOneAndReplace(ctx, filter, replacement any, opts ...any) *gomock.Call

FindOneAndReplace indicates an expected call of FindOneAndReplace.

func (*MockmonCollectionMockRecorder) FindOneAndUpdate

func (mr *MockmonCollectionMockRecorder) FindOneAndUpdate(ctx, filter, update any, opts ...any) *gomock.Call

FindOneAndUpdate indicates an expected call of FindOneAndUpdate.

func (*MockmonCollectionMockRecorder) Indexes

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

Indexes indicates an expected call of Indexes.

func (*MockmonCollectionMockRecorder) InsertMany

func (mr *MockmonCollectionMockRecorder) InsertMany(ctx, documents any, opts ...any) *gomock.Call

InsertMany indicates an expected call of InsertMany.

func (*MockmonCollectionMockRecorder) InsertOne

func (mr *MockmonCollectionMockRecorder) InsertOne(ctx, document any, opts ...any) *gomock.Call

InsertOne indicates an expected call of InsertOne.

func (*MockmonCollectionMockRecorder) ReplaceOne

func (mr *MockmonCollectionMockRecorder) ReplaceOne(ctx, filter, replacement any, opts ...any) *gomock.Call

ReplaceOne indicates an expected call of ReplaceOne.

func (*MockmonCollectionMockRecorder) UpdateByID

func (mr *MockmonCollectionMockRecorder) UpdateByID(ctx, id, update any, opts ...any) *gomock.Call

UpdateByID indicates an expected call of UpdateByID.

func (*MockmonCollectionMockRecorder) UpdateMany

func (mr *MockmonCollectionMockRecorder) UpdateMany(ctx, filter, update any, opts ...any) *gomock.Call

UpdateMany indicates an expected call of UpdateMany.

func (*MockmonCollectionMockRecorder) UpdateOne

func (mr *MockmonCollectionMockRecorder) UpdateOne(ctx, filter, update any, opts ...any) *gomock.Call

UpdateOne indicates an expected call of UpdateOne.

func (*MockmonCollectionMockRecorder) Watch

func (mr *MockmonCollectionMockRecorder) Watch(ctx, pipeline any, opts ...any) *gomock.Call

Watch indicates an expected call of Watch.

type MockmonSession

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

MockmonSession is a mock of monSession interface.

func NewMockmonSession

func NewMockmonSession(ctrl *gomock.Controller) *MockmonSession

NewMockmonSession creates a new mock instance.

func (*MockmonSession) AbortTransaction

func (m *MockmonSession) AbortTransaction(ctx context.Context) error

AbortTransaction mocks base method.

func (*MockmonSession) CommitTransaction

func (m *MockmonSession) CommitTransaction(ctx context.Context) error

CommitTransaction mocks base method.

func (*MockmonSession) EXPECT

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

func (*MockmonSession) EndSession

func (m *MockmonSession) EndSession(ctx context.Context)

EndSession mocks base method.

func (*MockmonSession) WithTransaction

func (m *MockmonSession) WithTransaction(ctx context.Context, fn func(context.Context) (any, error), opts ...options.Lister[options.TransactionOptions]) (any, error)

WithTransaction mocks base method.

type MockmonSessionMockRecorder

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

MockmonSessionMockRecorder is the mock recorder for MockmonSession.

func (*MockmonSessionMockRecorder) AbortTransaction

func (mr *MockmonSessionMockRecorder) AbortTransaction(ctx any) *gomock.Call

AbortTransaction indicates an expected call of AbortTransaction.

func (*MockmonSessionMockRecorder) CommitTransaction

func (mr *MockmonSessionMockRecorder) CommitTransaction(ctx any) *gomock.Call

CommitTransaction indicates an expected call of CommitTransaction.

func (*MockmonSessionMockRecorder) EndSession

func (mr *MockmonSessionMockRecorder) EndSession(ctx any) *gomock.Call

EndSession indicates an expected call of EndSession.

func (*MockmonSessionMockRecorder) WithTransaction

func (mr *MockmonSessionMockRecorder) WithTransaction(ctx, fn any, opts ...any) *gomock.Call

WithTransaction indicates an expected call of WithTransaction.

type Model

type Model struct {
	Collection
	// contains filtered or unexported fields
}

Model is a mongodb store model that represents a collection.

func MustNewModel

func MustNewModel(uri, db, collection string, opts ...Option) *Model

MustNewModel returns a Model, exits on errors.

func NewModel

func NewModel(uri, db, collection string, opts ...Option) (*Model, error)

NewModel returns a Model.

func (*Model) Aggregate

func (m *Model) Aggregate(ctx context.Context, v, pipeline any,
	opts ...options.Lister[options.AggregateOptions]) error

Aggregate executes an aggregation pipeline.

func (*Model) DeleteMany

func (m *Model) DeleteMany(ctx context.Context, filter any,
	opts ...options.Lister[options.DeleteManyOptions]) (int64, error)

DeleteMany deletes documents that match the filter.

func (*Model) DeleteOne

func (m *Model) DeleteOne(ctx context.Context, filter any,
	opts ...options.Lister[options.DeleteOneOptions]) (int64, error)

DeleteOne deletes the first document that matches the filter.

func (*Model) Find

func (m *Model) Find(ctx context.Context, v, filter any,
	opts ...options.Lister[options.FindOptions]) error

Find finds documents that match the filter.

func (*Model) FindOne

func (m *Model) FindOne(ctx context.Context, v, filter any,
	opts ...options.Lister[options.FindOneOptions]) error

FindOne finds the first document that matches the filter.

func (*Model) FindOneAndDelete

func (m *Model) FindOneAndDelete(ctx context.Context, v, filter any,
	opts ...options.Lister[options.FindOneAndDeleteOptions]) error

FindOneAndDelete finds a single document and deletes it.

func (*Model) FindOneAndReplace

func (m *Model) FindOneAndReplace(ctx context.Context, v, filter, replacement any,
	opts ...options.Lister[options.FindOneAndReplaceOptions]) error

FindOneAndReplace finds a single document and replaces it.

func (*Model) FindOneAndUpdate

func (m *Model) FindOneAndUpdate(ctx context.Context, v, filter, update any,
	opts ...options.Lister[options.FindOneAndUpdateOptions]) error

FindOneAndUpdate finds a single document and updates it.

func (*Model) StartSession

func (m *Model) StartSession(opts ...options.Lister[options.SessionOptions]) (sess *Session, err error)

StartSession starts a new session.

type Option

type Option func(opts *clientOptions)

Option defines the method to customize a mongo model.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout set the mon client operation timeout.

func WithTypeCodec

func WithTypeCodec(typeCodecs ...TypeCodec) Option

WithTypeCodec registers TypeCodecs to convert custom types.

type ResultHandler

type ResultHandler func(*mongo.InsertManyResult, error)

ResultHandler is a handler that used to handle results.

type Session

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

func (*Session) AbortTransaction

func (w *Session) AbortTransaction(ctx context.Context) (err error)

AbortTransaction implements the mongo.session interface.

func (*Session) CommitTransaction

func (w *Session) CommitTransaction(ctx context.Context) (err error)

CommitTransaction implements the mongo.session interface.

func (*Session) EndSession

func (w *Session) EndSession(ctx context.Context)

EndSession implements the mongo.session interface.

func (*Session) WithTransaction

func (w *Session) WithTransaction(
	ctx context.Context,
	fn func(sessCtx context.Context) (any, error),
	opts ...options.Lister[options.TransactionOptions],
) (res any, err error)

WithTransaction implements the mongo.session interface.

type TypeCodec

type TypeCodec struct {
	ValueType reflect.Type
	Encoder   bson.ValueEncoder
	Decoder   bson.ValueDecoder
}

TypeCodec is a struct that stores specific type Encoder/Decoder.

Jump to

Keyboard shortcuts

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