metadata

package
v1.23.0 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

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 Repository

type Repository interface {
	Create(ctx context.Context, collection string, metadata *Metadata) error
	FindList(ctx context.Context, collection string, filter any) ([]*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