mongodb

package
v1.38.0 Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package mongodb is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JSON

type JSON map[string]any

JSON document to save on mongodb

func (*JSON) Scan

func (mj *JSON) Scan(value any) error

Scan unmarshall value data

func (JSON) Value

func (mj JSON) Value() (driver.Value, error)

Value return marshall value data

type Metadata

type Metadata struct {
	ID         primitive.ObjectID
	EntityID   string
	EntityName string
	Data       JSON
	CreatedAt  time.Time
	UpdatedAt  time.Time
}

Metadata is a struct designed to encapsulate payload data.

type MetadataMongoDBModel

type MetadataMongoDBModel struct {
	ID         primitive.ObjectID `bson:"_id,omitempty"`
	EntityID   string             `bson:"entity_id"`
	EntityName string             `bson:"entity_name"`
	Data       JSON               `bson:"metadata"`
	CreatedAt  time.Time          `bson:"created_at"`
	UpdatedAt  time.Time          `bson:"updated_at"`
}

MetadataMongoDBModel represents the metadata into mongodb context

func (*MetadataMongoDBModel) FromEntity

func (mmm *MetadataMongoDBModel) FromEntity(md *Metadata) error

FromEntity converts an entity.Metadata to MetadataMongoDBModel

func (*MetadataMongoDBModel) ToEntity

func (mmm *MetadataMongoDBModel) ToEntity() *Metadata

ToEntity converts an MetadataMongoDBModel to entity.Metadata

type MetadataMongoDBRepository

type MetadataMongoDBRepository struct {
	Database string
	// contains filtered or unexported fields
}

MetadataMongoDBRepository is a MongoDD-specific implementation of the MetadataRepository.

func NewMetadataMongoDBRepository

func NewMetadataMongoDBRepository(mc *mmongo.MongoConnection) *MetadataMongoDBRepository

NewMetadataMongoDBRepository returns a new instance of MetadataMongoDBLRepository using the given MongoDB connection.

func (*MetadataMongoDBRepository) Create

func (mmr *MetadataMongoDBRepository) Create(ctx context.Context, collection string, metadata *Metadata) error

Create inserts a new metadata entity into mongodb.

func (*MetadataMongoDBRepository) Delete

func (mmr *MetadataMongoDBRepository) Delete(ctx context.Context, collection, id string) error

Delete an metadata entity into mongodb.

func (*MetadataMongoDBRepository) FindByEntity

func (mmr *MetadataMongoDBRepository) FindByEntity(ctx context.Context, collection, id string) (*Metadata, error)

FindByEntity retrieves a metadata from the mongodb using the provided entity_id.

func (*MetadataMongoDBRepository) FindList

func (mmr *MetadataMongoDBRepository) FindList(ctx context.Context, collection string, filter http.QueryHeader) ([]*Metadata, error)

FindList retrieves metadata from the mongodb all metadata or a list by specify metadata.

func (*MetadataMongoDBRepository) Update

func (mmr *MetadataMongoDBRepository) Update(ctx context.Context, collection, id string, metadata map[string]any) error

Update an metadata entity into mongodb.

type MockRepository

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

MockRepository is a mock of Repository interface.

func NewMockRepository

func NewMockRepository(ctrl *gomock.Controller) *MockRepository

NewMockRepository creates a new mock instance.

func (*MockRepository) Create

func (m *MockRepository) Create(ctx context.Context, collection string, metadata *Metadata) error

Create mocks base method.

func (*MockRepository) Delete

func (m *MockRepository) Delete(ctx context.Context, collection, id string) error

Delete mocks base method.

func (*MockRepository) EXPECT

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

func (*MockRepository) FindByEntity

func (m *MockRepository) FindByEntity(ctx context.Context, collection, id string) (*Metadata, error)

FindByEntity mocks base method.

func (*MockRepository) FindList

func (m *MockRepository) FindList(ctx context.Context, collection string, filter http.QueryHeader) ([]*Metadata, error)

FindList mocks base method.

func (*MockRepository) Update

func (m *MockRepository) Update(ctx context.Context, collection, id string, metadata map[string]any) error

Update mocks base method.

type MockRepositoryMockRecorder

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

MockRepositoryMockRecorder is the mock recorder for MockRepository.

func (*MockRepositoryMockRecorder) Create

func (mr *MockRepositoryMockRecorder) Create(ctx, collection, metadata any) *gomock.Call

Create indicates an expected call of Create.

func (*MockRepositoryMockRecorder) Delete

func (mr *MockRepositoryMockRecorder) Delete(ctx, collection, id any) *gomock.Call

Delete indicates an expected call of Delete.

func (*MockRepositoryMockRecorder) FindByEntity

func (mr *MockRepositoryMockRecorder) FindByEntity(ctx, collection, id any) *gomock.Call

FindByEntity indicates an expected call of FindByEntity.

func (*MockRepositoryMockRecorder) FindList

func (mr *MockRepositoryMockRecorder) FindList(ctx, collection, filter any) *gomock.Call

FindList indicates an expected call of FindList.

func (*MockRepositoryMockRecorder) Update

func (mr *MockRepositoryMockRecorder) Update(ctx, collection, id, metadata any) *gomock.Call

Update indicates an expected call of Update.

type Repository

type Repository interface {
	Create(ctx context.Context, collection string, metadata *Metadata) error
	FindList(ctx context.Context, collection string, filter http.QueryHeader) ([]*Metadata, error)
	FindByEntity(ctx context.Context, collection, id string) (*Metadata, error)
	Update(ctx context.Context, collection, id string, metadata map[string]any) error
	Delete(ctx context.Context, collection, id string) error
}

Repository provides an interface for operations related on mongodb a metadata entities.

Jump to

Keyboard shortcuts

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