store

package
v0.0.0-...-ad423d6 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package store provides data persistence operations for resources.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrResourceNotFound      = errors.New("resource not found")
	ErrResourceIdExist       = errors.New("resource with id already exists")
	ErrInvalidApprovalStatus = errors.New("approval status must be 'modified' or 'approved'")
)

Functions

func InitDB

func InitDB(cfg *config.Config) (*gorm.DB, error)

InitDB initializes the database connection and runs migrations

Types

type DataStore

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

DataStore is the concrete implementation of Store

func (*DataStore) Close

func (s *DataStore) Close() error

Close closes the database connection

func (*DataStore) Resource

func (s *DataStore) Resource() Resource

Resource returns the Resource repository

type Resource

type Resource interface {
	List(ctx context.Context, opts *ResourceListOptions) (*ResourceListResult, error)
	Create(ctx context.Context, request model.Resource) (*model.Resource, error)
	Delete(ctx context.Context, id string) error
	Get(ctx context.Context, id string) (*model.Resource, error)
}

Resource defines the repository interface for Resource operations

func NewResource

func NewResource(db *gorm.DB) Resource

NewResource creates a new Resource repository

type ResourceListOptions

type ResourceListOptions struct {
	ProviderName *string
	PageSize     int
	PageToken    *string
}

ResourceListOptions contains optional fields for listing requests.

type ResourceListResult

type ResourceListResult struct {
	Resources     model.ResourceList
	NextPageToken *string
}

ResourceListResult contains the result of a List operation.

type ResourceStore

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

func (*ResourceStore) Create

func (s *ResourceStore) Create(ctx context.Context, request model.Resource) (*model.Resource, error)

func (*ResourceStore) Delete

func (s *ResourceStore) Delete(ctx context.Context, id string) error

func (*ResourceStore) Get

func (s *ResourceStore) Get(ctx context.Context, id string) (*model.Resource, error)

func (*ResourceStore) List

type Store

type Store interface {
	Close() error
	Resource() Resource
}

Store provides access to all repositories

func NewStore

func NewStore(db *gorm.DB) Store

NewStore creates a new DataStore with initialized repositories

Directories

Path Synopsis
Package model defines the database models for resource storage.
Package model defines the database models for resource storage.

Jump to

Keyboard shortcuts

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