models

package
v0.0.0-...-c4e1ff2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AddGroupQuery = `
		INSERT INTO users_group
			(user_id, group_id)
		VALUES
			(:userID, :groupID);
	`
)

Variables

This section is empty.

Functions

func Commit

func Commit(tx *sqlx.Tx, err error)

func CreateFile

func CreateFile(file File, fileContent []byte) (uint64, error)

Types

type Equipment

type Equipment struct {
	Id   uint64 `db:"id"`
	Name string `json:"name" db:"name"`
}

func GetEquipments

func GetEquipments() ([]*Equipment, error)

func (*Equipment) GetFilesByEquipment

func (e *Equipment) GetFilesByEquipment() ([]*File, error)

func (*Equipment) Insert

func (e *Equipment) Insert() error

type Event

type Event struct {
	Id          uint64    `db:"id"`
	Title       string    `json:"title" db:"title"`
	Description string    `json:"description" db:"description"`
	Start_date  time.Time `json:"start_date" db:"start_date"`
	End_date    time.Time `json:"end_date" db:"end_date"`
	OwnerID     uint64    `json:"owner" db:"owner"`
	ImageID     uint64    `json:"image" db:"image"`
}

func GetCurrentEvents

func GetCurrentEvents() ([]*Event, error)

func GetEvents

func GetEvents() ([]*Event, error)

func GetPastEvents

func GetPastEvents() ([]*Event, error)

func GetUpcomingEvents

func GetUpcomingEvents() ([]*Event, error)

func (*Event) Insert

func (e *Event) Insert() error

type File

type File struct {
	Id          uint64 `json:"-" db:"id"`
	Permission  uint32 `json:"-" db:"permission"` // 0 is public, 1 is private
	OwnerID     uint64 `json:"owner" db:"owner_id"`
	GroupID     uint64 `json:"-" db:"group_id"` // TODO: Could be many groups
	EquipmentID uint64 `json:"-" db:"equipment_id"`

	// file path is ./files/$(file_hash)$(file_name)
	Filename string `json:"filename" db:"file_name"`
	Filehash []byte `json:"-" db:"file_hash"`
}

func GetFileByHash

func GetFileByHash(hash []byte) (*File, error)

func GetFileById

func GetFileById(id uint64) (*File, error)

func GetFiles

func GetFiles() ([]*File, error)

func GetUserFiles

func GetUserFiles(email string) ([]*File, error)

type Group

type Group struct {
	Id   uint64 `json:"-" db:"id"`
	Name string `json:"name" db:"name"`
}

func GetGroup

func GetGroup(name string) (*Group, error)

func GetGroups

func GetGroups() ([]*Group, error)

func (*Group) Insert

func (g *Group) Insert() error

type Inventory

type Inventory struct {
	Id      uint64 `db:"id"`
	GroupID uint64 `json:"groupId" db:"group_id"`
	Name    string `json:"name" db:"name"`
	Amount  uint64 `json:"amount" db:"amount"`
}

func GetInventories

func GetInventories() ([]*Inventory, error)

func (*Inventory) Insert

func (i *Inventory) Insert() error

type Participant

type Participant struct {
	Id      uint64 `db:"id"`
	EventID uint64 `json:"eventId" db:"event_id"`
	UserID  uint64 `json:"userId" db:"user_id"`
}

func (*Participant) Insert

func (p *Participant) Insert() error

type User

type User struct {
	Id        uint64 `json:"-" db:"id"`
	Email     string `json:"email" db:"email"`
	FirstName string `json:"firstname" db:"first_name"`
	LastName  string `json:"lastname" db:"last_name"`
}

func GetUserByMail

func GetUserByMail(email string) (*User, error)

func GetUsers

func GetUsers() ([]*User, error)

func (*User) AddGroup

func (u *User) AddGroup(group *Group) error

func (*User) GetGroups

func (u *User) GetGroups() ([]Group, error)

func (*User) Insert

func (u *User) Insert() error

type UserGroup

type UserGroup struct {
	Id      uint64 `db:"id"`
	UserId  uint64 `db:"userID"`
	GroupId uint64 `db:"groupID"`
}

Jump to

Keyboard shortcuts

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