models

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Init

func Init(db *gorm.DB)

Init initializes all models and creates tables if not already present

Types

type Base

type Base struct {
	ID        uint      `gorm:"primary_key" json:"id"`
	CreatedAt time.Time `json:"created_at"`
	UpdatedAt time.Time `json:"updated_at"`
}

Base is the base model for all tables

type Donation added in v1.1.0

type Donation struct {
	Base
	FirstName string `json:"first_name" binding:"required"`
	LastName  string `json:"last_name" binding:"required"`
	Message   string `json:"message" binding:"required"`
	Amount    string `json:"amount" binding:"required"`
}

Donation model for the donation table

type Guest

type Guest struct {
	Base
	FirstName    string     `json:"first_name" binding:"required"`
	LastName     string     `json:"last_name" binding:"required"`
	InvitationID uint       `json:"invitation_id" binding:"required"`
	Invitation   Invitation `json:"invitation" binding:"required"`
	RSVP         bool       `json:"rsvp" binding:"required"`
}

Guest model for the guest table

type Invitation

type Invitation struct {
	Base
	Name            string `json:"name" binding:"required"`
	Message         string `json:"message" binding:"required"`
	GuestCount      int    `json:"guest_count" binding:"required"`
	Registered      bool   `json:"registered" binding:"required"`
	Phone           string `json:"phone" binding:"required"`
	Email           string `json:"email" binding:"required"`
	RegistrationKey string `json:"registration_key" binding:"required" gorm:"index;"`
	Declined        bool   `json:"declined" binding:"required" gorm:"index;"`
}

Invitation model for the invitation table

func (*Invitation) BeforeCreate

func (i *Invitation) BeforeCreate(tx *gorm.DB) error

BeforeCreate creates a random uuid registration key for new invitations

Jump to

Keyboard shortcuts

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