db

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2022 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DB *bun.DB

Functions

func CheckAuthID

func CheckAuthID(authId string) (User, AuthID, bool)

func Init

func Init(logger *log.Logger)

func InitHeadless

func InitHeadless() error

Function returns when the database connection is established or fails

Types

type AuthID

type AuthID struct {
	bun.BaseModel `bun:"table:auth_tokens"`
	ID            string
	UID           string `bun:"uid"`
	IssuedAt      time.Time
}

func GetAuthID

func GetAuthID(token string) (AuthID, error)

type Course

type Course struct {
	bun.BaseModel `bun:"table:courses"`
	ID            string `json:"id" bun:",pk,type:uuid"`
	Subject       string `json:"subject" bun:",type:uuid"`
	GradeLevel    int16  `json:"grade_level"`
	Title         string `json:"title"`
	ShortName     string `json:"short_name"`
	Description   string `json:"description"`

	School     string `json:"school" bun:",type:uuid"`
	SchoolYear string `json:"school_year"`

	CreditHours float32 `json:"credit_hours"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetCourse

func GetCourse(id string) (Course, error)

type School

type School struct {
	bun.BaseModel `bun:"table:schools"`
	ID            string `json:"id" bun:",pk,type:uuid"`
	SchoolYear    int16  `json:"school_year"`

	Title                string  `json:"title"`
	ShortName            string  `json:"short_name"`
	Address              address `json:"address"`
	Principal            string  `json:"principal" bun:",type:uuid"`
	WebAddress           string  `json:"web_address"`
	SchoolNumber         string  `json:"school_number"`
	ScheduleRotationDays int     `json:"schedule_rotation_days"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetSchool

func GetSchool(id string) (School, error)

type User

type User struct {
	bun.BaseModel `bun:"table:users"`
	Subject       string `json:"-" bun:"sub"`
	Issuer        string `json:"-" bun:"iss"`
	ID            string `json:"id" bun:",pk,type:uuid"`

	GivenName  string `json:"given_name"`
	FamilyName string `json:"family_name"`
	MiddleName string `json:"middle_name"`
	NameSuffix string `json:"name_suffix"`
	Email      string `json:"email"`

	School     string                 `json:"school" bun:",type:uuid"`
	CustomData map[string]interface{} `json:"custom_data"`

	UserPreferences map[string]interface{} `json:"user_preferences"`
	LastLogin       time.Time              `json:"last_login"`

	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

func GetUser

func GetUser(id string) (User, error)

Jump to

Keyboard shortcuts

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