models

package
v0.0.0-...-6007bc2 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DBConn database access
	DBConn *gorm.DB
	// RedisClient redis cache access
	RedisClient redis.Client
)

Functions

func Config

func Config(key string) string

Config retrieves env vars

func InitDatabase

func InitDatabase()

InitDatabase configures database connection from environment variables

Types

type DelForum

type DelForum struct {
	Csrf string `json:"csrf" form:"csrf"`
}

DelForum form model

type Forum

type Forum struct {
	gorm.Model
	Name        string `json:"name" gorm:"not null" form:"name"`
	Description string `json:"description" gorm:"size:256"`
	Open        bool   `json:"Open" gorm:"default:true"`
	UserID      uint   `json:"userid" gorm:"not null"`
	User        User
	Threads     []Thread
	Members     []Member
	Tags        []Tag `gorm:"many2many:forum_tags;"`
}

Forum model

type GUser

type GUser struct {
	Name    string `json:"name"`
	Picture string `json:"picture"`
	Email   string `json:"email"`
}

GUser model for Google Sign-in user information

type Image

type Image struct {
	gorm.Model
	FileName string
	UserID   uint `json:"userid" gorm:"not null"`
	User     User
}

Image model for user uploaded image

type LoginUser

type LoginUser struct {
	Email string `json:"email"`
	Pass1 string `json:"pass1"`
	Csrf  string `json:"csrf" form:"csrf"`
}

LoginUser form model for user login

type Member

type Member struct {
	gorm.Model
	ForumID uint `json:"ForumID" gorm:"not null"`
	Forum   Forum
	UserID  uint `json:"UserID" gorm:"not null"`
	User    User
}

Member model for forum member

type NewForum

type NewForum struct {
	Name        string `json:"name" form:"name"`
	Description string `json:"description" form:"description"`
	Csrf        string `json:"csrf" form:"csrf"`
}

NewForum form model

type NewPost

type NewPost struct {
	Body string `json:"body" form:"body"`
	Csrf string `json:"csrf" form:"csrf"`
}

NewPost model for new post form

type NewThread

type NewThread struct {
	Title string `json:"title" form:"title"`
	Body  string `json:"body" form:"body"`
	Csrf  string `json:"csrf" form:"csrf"`
}

NewThread form model for new thread

type NewUser

type NewUser struct {
	DisplayName string `json:"DisplayName"`
	Email       string `json:"email"`
	Pass1       string `json:"pass1"`
	Pass2       string `json:"pass2"`
	Csrf        string `json:"csrf" form:"csrf"`
}

NewUser form model for new user registration

type PendingMember

type PendingMember struct {
	gorm.Model
	ForumID uint `json:"ForumID" gorm:"not null"`
	Forum   Forum
	UserID  uint `json:"UserID" gorm:"not null"`
	User    User
}

PendingMember model for pending member requests to join private forum

type Post

type Post struct {
	gorm.Model
	Body     string `json:"body" gorm:"not null"`
	UserID   uint   `json:"userid" gorm:"not null"`
	User     User
	ThreadID uint `json:"thread_id" gorm:"not null"`
	Thread   Thread
}

Post model for post reply in a thread

type Tag

type Tag struct {
	gorm.Model
	Name string
}

Tag is a keyword tag for groups

type Thread

type Thread struct {
	gorm.Model
	Title   string    `json:"title" gorm:"not null"`
	Body    string    `json:"body" gorm:"not null"`
	Date    time.Time `json:"date" `
	UserID  uint      `json:"userid" gorm:"not null"`
	User    User
	ForumID uint `json:"forum_id" gorm:"constraint:OnDelete:CASCADE;"`
	Forum   Forum
	Posts   []Post `json:""`
}

Thread model for thread

type UpdateForum

type UpdateForum struct {
	Name        string `json:"name" form:"name"`
	Description string `json:"description" form:"description"`
	Open        bool   `json:"Open" form:"open"`
	Csrf        string `json:"csrf" form:"csrf"`
}

UpdateForum form model

type UpdateThread

type UpdateThread struct {
	Title string    `json:"title" form:"title"`
	Body  string    `json:"body" form:"body"`
	Csrf  string    `json:"csrf" form:"csrf"`
	Date  time.Time `json:"date" form:"date"`
}

UpdateThread form model for update thread

type User

type User struct {
	gorm.Model
	DisplayName string   `json:"DisplayName" gorm:"unique;not null"`
	Email       string   `json:"email" gorm:"unique;not null"`
	Picture     string   `json:"picture"`
	Password    []byte   `json:"-"`
	Posts       []Post   `json:"-"`
	Threads     []Thread `json:"-"`
	Forums      []Forum  `json:"-"`
}

User model for user

Jump to

Keyboard shortcuts

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