models

package
v0.0.0-...-3a044c6 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TIME_LAYOUT = "2006-01-02 15:04:05"
)

Variables

View Source
var (
	ErrNoRecords        = errors.New("no records were found")
	ErrCommandOwnership = errors.New("user did not create command")
	ErrDoesNotExist     = errors.New("record does not exist")
	ErrUniqueConstraint = errors.New("record already exists")
)

Functions

This section is empty.

Types

type Soundbite

type Soundbite struct {
	ID       int
	Name     string
	Username string
	UserID   string
	FilePath string
	FileHash string
	Created  time.Time
}

Struct to present a record in the 'soundbites' table

type SoundbiteModel

type SoundbiteModel struct {
	DB *sql.DB
}

Struct that holds the database connectivity

func (*SoundbiteModel) Delete

func (m *SoundbiteModel) Delete(name, uid string) error

Deletes the soundbite if the user_id and name belong to the same record

func (*SoundbiteModel) Exists

func (m *SoundbiteModel) Exists(name, hash string) (bool, error)

Check whether a soundbite exists based on the name of the command and it's filehash

func (*SoundbiteModel) Get

func (m *SoundbiteModel) Get(name string) (*Soundbite, error)

Gets a Soundbite based on the name command

func (*SoundbiteModel) GetAll

func (m *SoundbiteModel) GetAll() ([]*Soundbite, error)

Get all the soundbites in the 'soundbites' table

func (*SoundbiteModel) Initialize

func (m *SoundbiteModel) Initialize() error

Initialize the 'soundbites' table in the sqlite db

func (*SoundbiteModel) Insert

func (m *SoundbiteModel) Insert(name, username, uid, filepath, filehash string) (int, error)

Insert Soundbites metadata into the 'soundbites' table

func (*SoundbiteModel) UpdateName

func (m *SoundbiteModel) UpdateName(oldName, newName string) error

Jump to

Keyboard shortcuts

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