models

package
v0.0.0-...-d0ca659 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Models keep track of data processing, such as returning slices for complex queries, or sanitizing input data

Index

Constants

This section is empty.

Variables

View Source
var (
	Basepath = filepath.Dir(b)
)

Functions

func CreateSyllabiTable

func CreateSyllabiTable() error

func DeleteAttachment

func DeleteAttachment(id int) error

func DeleteSyllabus

func DeleteSyllabus(id int) error

func DeleteToken

func DeleteToken(id int) error

func InitDB

func InitDB(url string) (*bun.DB, error)

func RemoveFixtures

func RemoveFixtures(t *testing.T)

func RunFixtures

func RunFixtures(db *bun.DB, dir string) error

func Shutdown

func Shutdown() error

Types

type Attachment

type Attachment struct {
	CreatedAt          time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt          time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	ID                 int64     `bun:"id,pk,autoincrement"`
	Name               string    `bun:"name,notnull" form:"name"`
	File               []byte    `bun:"file,notnull"`
	Type               string    `bun:"type,notnull"`
	SyllabusAttachedID int64     `yaml:"syllabus_attached_id"`
}

func AddNewAttachment

func AddNewAttachment(att *Attachment) (Attachment, error)

func GetAllAttachments

func GetAllAttachments() ([]Attachment, error)

func GetAttachment

func GetAttachment(id int) (Attachment, error)

func UpdateAttachment

func UpdateAttachment(id int, att *Attachment) (Attachment, error)

type Contributor

type Contributor struct {
	CreatedAt time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt time.Time   `bun:",nullzero,notnull,default:current_timestamp"`
	ID        int64       `bun:"id,pk,autoincrement"`
	Name      string      `bun:"name,notnull"`
	Email     string      `bun:"email,notnull,unique"`
	Syllabi   []*Syllabus `bun:"rel:has-many" form:"syllabi" json:"syllabi"`
}

type MagicToken

type MagicToken struct {
	CreatedAt       time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt       time.Time `bun:",nullzero,notnull,default:current_timestamp"`
	ID              int64     `bun:"id,pk,autoincrement"`
	Token           []byte    `bun:"token,notnull"`
	SyllabusTokenID int64     `bun:"syllabus_token_id" yaml:"syllabus_token_id"`
}

func AddNewToken

func AddNewToken(token *MagicToken) (MagicToken, error)

func GetTokenSyllabus

func GetTokenSyllabus(id int) (MagicToken, error)

type Syllabus

type Syllabus struct {
	CreatedAt     time.Time     `bun:",nullzero,notnull,default:current_timestamp"`
	UpdatedAt     time.Time     `bun:",nullzero,notnull,default:current_timestamp"`
	ID            int64         `bun:"id,pk,autoincrement"`
	Title         string        `bun:"title,notnull" form:"title" json:"title"`
	Description   string        `form:"description" json:"description"`
	Email         string        `bun:"email,notnull" form:"email" json:"email"`
	Attachments   []*Attachment `bun:"rel:has-many,join:id=syllabus_attached_id"`
	ContributorID int64         `yaml:"contributor_id"`
	Contributor   *Contributor  `bun:"rel:belongs-to,join:contributor_id=id"`
}

func AddNewSyllabus

func AddNewSyllabus(syll *Syllabus) (Syllabus, error)

func GetAllSyllabi

func GetAllSyllabi() ([]Syllabus, error)

func GetSyllabus

func GetSyllabus(id int) (Syllabus, error)

func UpdateSyllabus

func UpdateSyllabus(id int, syll *Syllabus) (Syllabus, error)

Jump to

Keyboard shortcuts

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