model

package
v0.0.0-...-691959d Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyPassword

func VerifyPassword(hashedPassword, password string) error

VerifyPassword checks the known password hash against the hashed string that was provided

Types

type Base

type Base struct {
	ID        uuid.UUID `gorm:"type:uuid;primary_key;" json:"id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

Base holds technical fields

func (*Base) Prepare

func (b *Base) Prepare() error

Prepare initilises techncal fields

type Comment

type Comment struct {
	Base
	Message   string `gorm:"size:255;not null" json:"message"`
	User      User   `json:"author"`
	UserID    uuid.UUID
	Session   Session `json:"session"`
	SessionID uuid.UUID
}

Comment represents an user comment in a session

func (*Comment) Count

func (c *Comment) Count(db *gorm.DB) (int, error)

Count returns count of all known objects of this type

func (*Comment) Delete

func (c *Comment) Delete(db *gorm.DB) error

Delete is removing existing objects

func (*Comment) FindAll

func (c *Comment) FindAll(db *gorm.DB) (*[]Object, error)

FindAll returns all known objects of this type

func (*Comment) FindByID

func (c *Comment) FindByID(db *gorm.DB, uid uuid.UUID) error

FindByID returns an objects with corresponding ID if exists

func (*Comment) GetCreatedAt

func (c *Comment) GetCreatedAt() time.Time

GetCreatedAt returns the CreatedAt

func (*Comment) GetID

func (c *Comment) GetID() uuid.UUID

GetID returns the ID

func (*Comment) Save

func (c *Comment) Save(db *gorm.DB) error

Save saves the structure as new object

func (*Comment) SetCreatedAt

func (c *Comment) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the CreatedAt

func (*Comment) Update

func (c *Comment) Update(db *gorm.DB) error

Update updates the existing objects

func (*Comment) Validate

func (c *Comment) Validate(action string) error

Validate checks structure consistency

type Event

type Event struct {
	Base
	Name     string    `gorm:"size:255;not null;unique" json:"name"`
	Year     string    `gorm:"size:4;not null" json:"year"`
	Sessions []Session `gorm:"foreignkey:EventID"`
}

Event represents an event

func (*Event) Count

func (e *Event) Count(db *gorm.DB) (int, error)

Count returns count of all known objects of this type

func (*Event) Delete

func (e *Event) Delete(db *gorm.DB) error

Delete is removing existing objects

func (*Event) FindAll

func (e *Event) FindAll(db *gorm.DB) (*[]Object, error)

FindAll returns all known objects of this type

func (*Event) FindByID

func (e *Event) FindByID(db *gorm.DB, uid uuid.UUID) error

FindByID returns an objects with corresponding ID if exists

func (*Event) GetCreatedAt

func (e *Event) GetCreatedAt() time.Time

GetCreatedAt returns the CreatedAt

func (*Event) GetID

func (e *Event) GetID() uuid.UUID

GetID returns the ID

func (*Event) Save

func (e *Event) Save(db *gorm.DB) error

Save saves the structure as new object

func (*Event) SetCreatedAt

func (e *Event) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the CreatedAt

func (*Event) Update

func (e *Event) Update(db *gorm.DB) error

Update updates the existing objects

func (*Event) Validate

func (e *Event) Validate(action string) error

Validate checks structure consistency

type List

type List struct {
	Count int      `json:"count"`
	Data  []Object `json:"data"`
}

List holds technical fields

type Object

type Object interface {
	GetID() uuid.UUID
	GetCreatedAt() time.Time
	SetCreatedAt(createdAt time.Time)
	Save(db *gorm.DB) error
	Count(db *gorm.DB) (int, error)
	FindAll(db *gorm.DB) (*[]Object, error)
	FindByID(db *gorm.DB, uid uuid.UUID) error
	Update(db *gorm.DB) error
	Delete(db *gorm.DB) error
}

Object is an abstration of all Base objects

type Session

type Session struct {
	Base
	Name          string `gorm:"size:255;not null;unique" json:"name"`
	User          User   `json:"author"`
	UserID        uuid.UUID
	Event         Event `json:"event"`
	EventID       uuid.UUID
	Subscriptions []Subscription `gorm:"foreignkey:SessionID"`
	Comments      []Comment      `gorm:"foreignkey:SessionID"`
}

Session represents a session

func (*Session) Count

func (s *Session) Count(db *gorm.DB) (int, error)

Count returns count of all known objects of this type

func (*Session) Delete

func (s *Session) Delete(db *gorm.DB) error

Delete is removing existing objects

func (*Session) FindAll

func (s *Session) FindAll(db *gorm.DB) (*[]Object, error)

FindAll returns all known objects of this type

func (*Session) FindByID

func (s *Session) FindByID(db *gorm.DB, uid uuid.UUID) error

FindByID returns an objects with corresponding ID if exists

func (*Session) GetCreatedAt

func (s *Session) GetCreatedAt() time.Time

GetCreatedAt returns the CreatedAt

func (*Session) GetID

func (s *Session) GetID() uuid.UUID

GetID returns the ID

func (*Session) Save

func (s *Session) Save(db *gorm.DB) error

Save saves the structure as new object

func (*Session) SetCreatedAt

func (s *Session) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the CreatedAt

func (*Session) Update

func (s *Session) Update(db *gorm.DB) error

Update updates the existing objects

func (*Session) Validate

func (s *Session) Validate(action string) error

Validate checks structure consistency

type Subscription

type Subscription struct {
	Base
	User      User `json:"user"`
	UserID    uuid.UUID
	Session   Session `json:"session"`
	SessionID uuid.UUID
}

Subscription represents a session subscription

func (*Subscription) Count

func (s *Subscription) Count(db *gorm.DB) (int, error)

Count returns count of all known objects of this type

func (*Subscription) Delete

func (s *Subscription) Delete(db *gorm.DB) error

Delete is removing existing objects

func (*Subscription) FindAll

func (s *Subscription) FindAll(db *gorm.DB) (*[]Object, error)

FindAll returns all known objects of this type

func (*Subscription) FindByID

func (s *Subscription) FindByID(db *gorm.DB, uid uuid.UUID) error

FindByID returns an objects with corresponding ID if exists

func (*Subscription) GetCreatedAt

func (s *Subscription) GetCreatedAt() time.Time

GetCreatedAt returns the CreatedAt

func (*Subscription) GetID

func (s *Subscription) GetID() uuid.UUID

GetID returns the ID

func (*Subscription) Save

func (s *Subscription) Save(db *gorm.DB) error

Save saves the structure as new object

func (*Subscription) SetCreatedAt

func (s *Subscription) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the CreatedAt

func (*Subscription) Update

func (s *Subscription) Update(db *gorm.DB) error

Update updates the existing objects

func (*Subscription) Validate

func (s *Subscription) Validate(action string) error

Validate checks structure consistency

type User

type User struct {
	Base
	Name          string         `gorm:"size:255;not null;unique" json:"name"`
	Email         string         `gorm:"size:100;not null;unique" json:"email"`
	Password      string         `gorm:"size:100;not null;" json:"password"`
	Subscriptions []Subscription `gorm:"foreignkey:UserID"`
	Sessions      []Session      `gorm:"foreignkey:UserID"`
	Comments      []Comment      `gorm:"foreignkey:UserID"`
}

User represents an user

func (*User) Count

func (u *User) Count(db *gorm.DB) (int, error)

Count returns count of all known objects of this type

func (*User) Delete

func (u *User) Delete(db *gorm.DB) error

Delete is removing existing objects

func (*User) FindAll

func (u *User) FindAll(db *gorm.DB) (*[]Object, error)

FindAll returns all known objects of this type

func (*User) FindByID

func (u *User) FindByID(db *gorm.DB, uid uuid.UUID) error

FindByID returns an objects with corresponding ID if exists

func (*User) GetCreatedAt

func (u *User) GetCreatedAt() time.Time

GetCreatedAt returns the CreatedAt

func (*User) GetID

func (u *User) GetID() uuid.UUID

GetID returns the ID

func (*User) Save

func (u *User) Save(db *gorm.DB) error

Save saves the structure as new object

func (*User) SetCreatedAt

func (u *User) SetCreatedAt(createdAt time.Time)

SetCreatedAt sets the CreatedAt

func (*User) Update

func (u *User) Update(db *gorm.DB) error

Update updates the existing objects

func (*User) Validate

func (u *User) Validate(action string) error

Validate checks structure consistency

Jump to

Keyboard shortcuts

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