Documentation
¶
Index ¶
- func ObjectID[T ~string](domainID T) primitive.ObjectID
- type RetryingStorage
- func (s *RetryingStorage) Delete(ctx context.Context, collection string, docID primitive.ObjectID) (deletedCount int64, err error)
- func (s *RetryingStorage) DeleteMany(ctx context.Context, collection string, filter interface{}) (deletedCount int64, err error)
- func (s *RetryingStorage) FindAll(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
- func (s *RetryingStorage) FindMany(ctx context.Context, collection string, filter interface{}, ...) (total uint64, err error)
- func (s *RetryingStorage) FindOne(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
- func (s *RetryingStorage) GetDatabaseName() string
- func (s *RetryingStorage) Insert(ctx context.Context, collection string, document interface{}) error
- func (s *RetryingStorage) RunInTransaction(ctx context.Context, fn func(context.Context) error) error
- func (s *RetryingStorage) Update(ctx context.Context, collection string, docID primitive.ObjectID, ...) (modifiedCount int64, err error)
- func (s *RetryingStorage) Upsert(ctx context.Context, collection string, docID interface{}, update interface{}) (upsertedCount int64, err error)
- type Storage
- func (s *Storage) Delete(ctx context.Context, collection string, docID primitive.ObjectID) (deletedCount int64, err error)
- func (s *Storage) DeleteMany(ctx context.Context, collection string, filter interface{}) (deletedCount int64, err error)
- func (s *Storage) FindAll(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
- func (s *Storage) FindMany(ctx context.Context, collection string, filter interface{}, ...) (total uint64, err error)
- func (s *Storage) FindOne(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
- func (s *Storage) GetDatabaseName() string
- func (s *Storage) Insert(ctx context.Context, collection string, document interface{}) error
- func (s *Storage) RunInTransaction(ctx context.Context, fn func(context.Context) error) error
- func (s *Storage) Update(ctx context.Context, collection string, docID primitive.ObjectID, ...) (modifiedCount int64, err error)
- func (s *Storage) Upsert(ctx context.Context, collection string, docID interface{}, update interface{}) (upsertedCount int64, err error)
- type StorageReader
- type StorageReaderWriter
- type StorageWriter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type RetryingStorage ¶
type RetryingStorage struct {
// contains filtered or unexported fields
}
RetryingStorage wraps StorageReaderWriter for read side
func NewRetry ¶
func NewRetry(upstream StorageReaderWriter, logger *zap.Logger) *RetryingStorage
NewRetry creates new mongostorage with retries
func (*RetryingStorage) Delete ¶
func (s *RetryingStorage) Delete(ctx context.Context, collection string, docID primitive.ObjectID) (deletedCount int64, err error)
Delete deletes document in the database.
func (*RetryingStorage) DeleteMany ¶
func (s *RetryingStorage) DeleteMany(ctx context.Context, collection string, filter interface{}) (deletedCount int64, err error)
DeleteMany deletes filtered documents in the database.
func (*RetryingStorage) FindAll ¶
func (s *RetryingStorage) FindAll(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
FindAll returns all rows matching filter into destination.
func (*RetryingStorage) FindMany ¶
func (s *RetryingStorage) FindMany(ctx context.Context, collection string, filter interface{}, limit, offset uint64, sort string, dest interface{}) (total uint64, err error)
FindMany returns rows into destination.
func (*RetryingStorage) FindOne ¶
func (s *RetryingStorage) FindOne(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
FindOne returns a row into destination.
func (*RetryingStorage) GetDatabaseName ¶
func (s *RetryingStorage) GetDatabaseName() string
GetDatabaseName returns the name of the current database.
func (*RetryingStorage) Insert ¶
func (s *RetryingStorage) Insert(ctx context.Context, collection string, document interface{}) error
Insert makes insert into database.
func (*RetryingStorage) RunInTransaction ¶
func (s *RetryingStorage) RunInTransaction(ctx context.Context, fn func(context.Context) error) error
RunInTransaction encapsulates the function that needs to run in a transaction.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage manages query builders and database requests.
func (*Storage) Delete ¶
func (s *Storage) Delete(ctx context.Context, collection string, docID primitive.ObjectID) (deletedCount int64, err error)
Delete deletes document in the database.
func (*Storage) DeleteMany ¶
func (s *Storage) DeleteMany(ctx context.Context, collection string, filter interface{}) (deletedCount int64, err error)
DeleteMany deletes filtered documents in the database.
func (*Storage) FindAll ¶
func (s *Storage) FindAll(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
FindAll returns all rows matching filter into destination.
func (*Storage) FindMany ¶
func (s *Storage) FindMany( ctx context.Context, collection string, filter interface{}, limit, offset uint64, sort string, dest interface{}, ) (total uint64, err error)
FindMany returns rows into destination.
func (*Storage) FindOne ¶
func (s *Storage) FindOne(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error)
FindOne returns a row into destination.
func (*Storage) GetDatabaseName ¶
GetDatabaseName returns the name of the current database
func (*Storage) RunInTransaction ¶
RunInTransaction encapsulates the function that needs to run in a transaction.
type StorageReader ¶
type StorageReader interface { FindOne(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error) FindAll(ctx context.Context, collection string, filter interface{}, dest interface{}) (err error) FindMany( ctx context.Context, collection string, filter interface{}, limit, offset uint64, sort string, dest interface{}, ) (total uint64, err error) }
StorageReader describes interface for read operations for mongostorage
type StorageReaderWriter ¶
type StorageReaderWriter interface { StorageReader StorageWriter GetDatabaseName() string }
StorageReaderWriter describes interface for both read and write operations for mongostorage
type StorageWriter ¶
type StorageWriter interface { RunInTransaction(ctx context.Context, fn func(context.Context) error) error Insert(ctx context.Context, collection string, document interface{}) error Update(ctx context.Context, collection string, docID primitive.ObjectID, update interface{}) (modifiedCount int64, err error) Upsert(ctx context.Context, collection string, docID interface{}, update interface{}) (upsertedCount int64, err error) Delete(ctx context.Context, collection string, docID primitive.ObjectID) (deletedCount int64, err error) DeleteMany(ctx context.Context, collection string, filter interface{}) (deletedCount int64, err error) }
StorageWriter describes interface for write operations for mongostorage