db

package
v0.0.0-...-ea1fb9e Latest Latest
Warning

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

Go to latest
Published: May 19, 2022 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_TABLE = "default_table"

Variables

View Source
var (
	ErrDuplicate            = errors.New("record already exists")
	ErrNotFound             = errors.New("record does not exist")
	ErrUpdateFailed         = errors.New("record could not be updated")
	ErrDeleteFailed         = errors.New("record could not be deleted")
	ErrInvalidID            = errors.New("record ID is invalid")
	ErrInvalidEmail         = errors.New("email is not valid")
	ErrInvalidName          = errors.New("name is not valid")
	ErrInvalidUsername      = errors.New("username is not valid")
	ErrInvalidTableName     = errors.New("tablename is not valid")
	ErrTableExists          = errors.New("table already exists")
	ErrTableDoesNotExist    = errors.New("table does not exist")
	ErrTableCannotBeDeleted = errors.New("table cannot be deleted")
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	ID       int64
	Name     string
	Username string
	Email    string
}

func NewEntry

func NewEntry(name, username, email string) (*Entry, error)

func (*Entry) Display

func (e *Entry) Display(writer io.Writer)

type SQLiteRepository

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

func NewSQLiteRepository

func NewSQLiteRepository(db *sql.DB) (*SQLiteRepository, error)

func SetupWithInserts

func SetupWithInserts(t *testing.T) (*SQLiteRepository, func())

func (*SQLiteRepository) All

func (r *SQLiteRepository) All() (all []*Entry, err error)

func (*SQLiteRepository) ClearTable

func (r *SQLiteRepository) ClearTable() error

Wipes the current table.

Logs to console and terminates execution if there is an issue with SQL

func (*SQLiteRepository) CurrentTable

func (r *SQLiteRepository) CurrentTable() string

func (*SQLiteRepository) Delete

func (r *SQLiteRepository) Delete(username string) error

func (*SQLiteRepository) DeleteTable

func (r *SQLiteRepository) DeleteTable(tableName string) error

func (*SQLiteRepository) GetByUsername

func (r *SQLiteRepository) GetByUsername(username string) (*Entry, error)

func (*SQLiteRepository) Initialize

func (r *SQLiteRepository) Initialize() error

func (*SQLiteRepository) Insert

func (r *SQLiteRepository) Insert(e Entry) (*Entry, error)

func (*SQLiteRepository) ListTables

func (r *SQLiteRepository) ListTables() (tables []string)

func (*SQLiteRepository) NewTable

func (r *SQLiteRepository) NewTable(tableName string) error

func (*SQLiteRepository) SwitchTable

func (r *SQLiteRepository) SwitchTable(tableName string) error

func (*SQLiteRepository) TableExists

func (r *SQLiteRepository) TableExists(tableName string) (bool, error)

func (*SQLiteRepository) Update

func (r *SQLiteRepository) Update(username string, u *Entry) (*Entry, error)

Jump to

Keyboard shortcuts

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