storage

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2025 License: Unlicense Imports: 18 Imported by: 0

Documentation

Overview

Package storage provides all storage related functionality.

Index

Constants

View Source
const (
	// DBTypeLocal is the variant of using a local postgresql database
	DBTypeLocal = "local"
	// DBTypeRemote is the variant of using a remote postgresql database
	DBTypeRemote = "remote"
)

Variables

View Source
var (
	// ErrStrainNotFound is returned when a strain is not found in the store.
	ErrStrainNotFound = errors.New("Strain with that product name not found")
	// ErrStrainAlreadyExists is returned when a strain with the same product name already exists in the store.
	ErrStrainAlreadyExists = errors.New("Strain with that product name already exists")
)
View Source
var BunDB *bun.DB

BunDB is the global database connection

View Source
var SupabaseClient *supabase.Client

SupabaseClient is the supabase client for the application

Functions

func CreateAccount

func CreateAccount(account *types.Account) error

CreateAccount creates an account in the database

func CreateAuthenticatedUser

func CreateAuthenticatedUser(user *types.AuthenticatedUser) error

CreateAuthenticatedUser creates an authenticated user in the database

func CreatePostgresDB

func CreatePostgresDB(dbname string, dbuser string, dbpassword string, dbhost string) (*sql.DB, error)

CreatePostgresDB creates a new database connection

func GetAccountByUserID

func GetAccountByUserID(userID uuid.UUID) (types.Account, error)

GetAccountByUserID retrieves an account by the user ID

func GetAuthenticatedUserByEmail

func GetAuthenticatedUserByEmail(email string) (types.AuthenticatedUser, error)

GetAuthenticatedUserByEmail retrieves an authenticated user by the email

func GetAuthenticatedUserByEmailAndPassword

func GetAuthenticatedUserByEmailAndPassword(email string, password string) (types.AuthenticatedUser, error)

GetAuthenticatedUserByEmailAndPassword retrieves an authenticated user by the email and password

func InitBunWithPostgres

func InitBunWithPostgres() error

InitBunWithPostgres initializes the bun database connection

func InitSupabaseClient

func InitSupabaseClient() error

InitSupabaseClient initializes the supabase client.

Types

type StrainStore

type StrainStore interface {
	AddStrain(s *can.Strain) error
	GetStrains() []*can.Strain
	FindStrainByProduct(p string) (*can.Strain, error)
}

StrainStore is an interface for storing strains.

type StrainStoreInMemory

type StrainStoreInMemory struct {
	Strains map[string]*can.Strain
}

StrainStoreInMemory is an in-memory store for strains at runtime

func NewStrainStoreInMemory

func NewStrainStoreInMemory() *StrainStoreInMemory

NewStrainStoreInMemory creates a new in-memory Strain store.

func (*StrainStoreInMemory) AddStrain

func (sstr *StrainStoreInMemory) AddStrain(s *can.Strain) error

AddStrain adds a strain to the store, using its product name as the key.

func (*StrainStoreInMemory) FindStrainByProduct added in v0.1.1

func (sstr *StrainStoreInMemory) FindStrainByProduct(p string) (*can.Strain, error)

FindStrainByProduct finds a strain in the store by product name.

func (*StrainStoreInMemory) GetStrains

func (sstr *StrainStoreInMemory) GetStrains() []*can.Strain

GetStrains returns all strains in the store as a slice.

Jump to

Keyboard shortcuts

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