store

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrConcurrentUpdate is returned when there is a concurrent update.
	ErrConcurrentUpdate = fmt.Errorf("store: concurrent update")
)

Functions

This section is empty.

Types

type BaseModel added in v0.5.0

type BaseModel struct {
	gorm.Model

	ModelID string `gorm:"uniqueIndex"`
	Path    string
}

BaseModel represents a base model.

type Model

type Model struct {
	gorm.Model

	ModelID  string `gorm:"uniqueIndex:idx_model_model_id_tenant_id"`
	TenantID string `gorm:"uniqueIndex:idx_model_model_id_tenant_id"`

	Path        string
	IsPublished bool
}

Model represents a model.

type ModelKey

type ModelKey struct {
	ModelID  string
	TenantID string
}

ModelKey represents a model key.

type ModelSpec added in v0.2.0

type ModelSpec struct {
	Key         ModelKey
	Path        string
	IsPublished bool
}

ModelSpec represents a model spec that is passed to CreateModel.

type S

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

S represents the data store.

func New

func New(db *gorm.DB) *S

New creates a new store instance.

func NewTest

func NewTest(t *testing.T) (*S, func())

NewTest returns a new test store.

func (*S) AutoMigrate

func (s *S) AutoMigrate() error

AutoMigrate sets up the auto-migration task of the database.

func (*S) CreateBaseModel added in v0.5.0

func (s *S) CreateBaseModel(modelID, path string) (*BaseModel, error)

CreateBaseModel creates a model.

func (*S) CreateModel

func (s *S) CreateModel(spec ModelSpec) (*Model, error)

CreateModel creates a model.

func (*S) DeleteModel

func (s *S) DeleteModel(k ModelKey) error

DeleteModel deletes a model by model ID and tenant ID.

func (*S) GetBaseModel added in v0.5.0

func (s *S) GetBaseModel(modelID string) (*BaseModel, error)

GetBaseModel returns a base model by model ID.

func (*S) GetModel

func (s *S) GetModel(k ModelKey, onlyPublished bool) (*Model, error)

GetModel returns a model by model ID and tenant ID.

func (*S) ListBaseModels added in v0.5.0

func (s *S) ListBaseModels() ([]*BaseModel, error)

ListBaseModels returns all base models.

func (*S) ListModelsByTenantID

func (s *S) ListModelsByTenantID(tenantID string, onlyPublished bool) ([]*Model, error)

ListModelsByTenantID finds models.

func (*S) UpdateModel added in v0.2.0

func (s *S) UpdateModel(k ModelKey, isPublished bool) error

UpdateModel updates the model.

Jump to

Keyboard shortcuts

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