models

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SessionCodeLength = 4
	SessionCodeMax    = 456976 // 26^4
)

Variables

This section is empty.

Functions

func Connect

func Connect() (*gorm.DB, error)

func ConnectWithDB

func ConnectWithDB(dialector gorm.Dialector) (*gorm.DB, error)

func ConnectWithSqlLite

func ConnectWithSqlLite(dbname string) (*gorm.DB, error)

func ConnectWithTestDB

func ConnectWithTestDB() (*gorm.DB, func())

Helper for testing

func MarshalID

func MarshalID(id uint) graphql.Marshaler

Lets redefine the base ID type to use an id from gorm's default uint type

func UnmarshalID

func UnmarshalID(v interface{}) (uint, error)

And the same for the unmarshaler

Types

type Participant

type Participant struct {
	*gorm.Model

	Name      string
	SessionID int
	Session   Session
}

func NewParticipant

func NewParticipant(db *gorm.DB, name string, sessionCode string) (*Participant, error)

func NewParticipantWithSession

func NewParticipantWithSession(db *gorm.DB, name string, session *Session) (*Participant, error)

type Session

type Session struct {
	gorm.Model

	Code         string
	Participants []Participant
}

func NewSession

func NewSession(db *gorm.DB) *Session

Jump to

Keyboard shortcuts

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