Documentation
¶
Overview ¶
Package storage provides all storage related functionality.
Index ¶
- Constants
- Variables
- func CreateAccount(account *types.Account) error
- func CreateAuthenticatedUser(user *types.AuthenticatedUser) error
- func CreatePostgresDB(dbname string, dbuser string, dbpassword string, dbhost string) (*sql.DB, error)
- func GetAccountByUserID(userID uuid.UUID) (types.Account, error)
- func GetAuthenticatedUserByEmail(email string) (types.AuthenticatedUser, error)
- func GetAuthenticatedUserByEmailAndPassword(email string, password string) (types.AuthenticatedUser, error)
- func InitBunWithPostgres() error
- func InitSupabaseClient() error
- type StrainStore
- type StrainStoreInMemory
Constants ¶
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 ¶
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") )
var BunDB *bun.DB
BunDB is the global database connection
var SupabaseClient *supabase.Client
SupabaseClient is the supabase client for the application
Functions ¶
func CreateAccount ¶
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 ¶
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 ¶
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.