database

package
v0.0.0-...-71330bb Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2022 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBEnv

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

DBEnv is the struct that holds this package together

func InitDB

func InitDB(dbType string, dsn string) (*DBEnv, error)

InitDB initializes database access and the connection pool

func (*DBEnv) CountStops

func (env *DBEnv) CountStops() (i int, err error)

func (*DBEnv) CreateSession

func (env *DBEnv) CreateSession(user *model.User) (*string, error)

func (*DBEnv) CreateUser

func (env *DBEnv) CreateUser(reg *model.UserRegistration) (*model.User, error)

Creates a new user in the database a QueryError is return if the username already exists (database constraints not met)

func (*DBEnv) GetStop

func (env *DBEnv) GetStop(id string) (*model.Stop, error)

func (*DBEnv) GetStops

func (env *DBEnv) GetStops() (stops []model.Stop, err error)

func (*DBEnv) Login

func (env *DBEnv) Login(login *model.UserLogin) (*model.User, error)

Login logs a user in if the password matches the hash in database a PasswordError is return if the passwords do not match a QueryError is returned if the username contains invalid sql characters like %

func (*DBEnv) Migrate

func (env *DBEnv) Migrate() error

Migrate performs the migrations of the database to the latest schema_version

func (*DBEnv) ReplaceAndImportStops

func (env *DBEnv) ReplaceAndImportStops(stops []model.Stop) error

func (*DBEnv) ResumeSession

func (env *DBEnv) ResumeSession(token string) (*model.User, error)

type InitError

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

database init error

func (InitError) Error

func (e InitError) Error() string

func (InitError) Unwrap

func (e InitError) Unwrap() error

type MigrationError

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

database migration error

func (MigrationError) Error

func (e MigrationError) Error() string

func (MigrationError) Unwrap

func (e MigrationError) Unwrap() error

type PasswordError

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

Password hash error

func (PasswordError) Error

func (e PasswordError) Error() string

func (PasswordError) Unwrap

func (e PasswordError) Unwrap() error

type QueryError

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

database query error

func (QueryError) Error

func (e QueryError) Error() string

func (QueryError) Unwrap

func (e QueryError) Unwrap() error

type TransactionError

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

database transaction error

func (TransactionError) Error

func (e TransactionError) Error() string

func (TransactionError) Unwrap

func (e TransactionError) Unwrap() error

Jump to

Keyboard shortcuts

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