store

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 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 File

type File struct {
	gorm.Model

	FileID   string `gorm:"uniqueIndex:idx_file_file_id_tenant_id"`
	TenantID string `gorm:"uniqueIndex:idx_file_file_id_tenant_id"`

	Filename string
	Purpose  string `gorm:"index:idx_file_tenant_id_purpose"`

	Bytes int64

	ObjectStorePath string
}

File represents a file.

type FileKey

type FileKey struct {
	FileID   string
	TenantID string
}

FileKey represents a file key.

type FileSpec

type FileSpec struct {
	Key FileKey

	Filename string
	Purpose  string
	Bytes    int64

	ObjectStorePath string
}

FileSpec is a spec of the file

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) CreateFile

func (s *S) CreateFile(spec FileSpec) (*File, error)

CreateFile creates a file.

func (*S) DeleteFile

func (s *S) DeleteFile(k FileKey) error

DeleteFile deletes a file by file ID and tenant ID.

func (*S) GetFile

func (s *S) GetFile(k FileKey) (*File, error)

GetFile returns a file by file ID and tenant ID.

func (*S) ListFilesByTenantID

func (s *S) ListFilesByTenantID(tenantID string) ([]*File, error)

ListFilesByTenantID list files.

func (*S) ListFilesByTenantIDAndPurpose

func (s *S) ListFilesByTenantIDAndPurpose(tenantID, purpose string) ([]*File, error)

ListFilesByTenantIDAndPurpose list files.

Jump to

Keyboard shortcuts

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