models

package
v2.0.0-...-0bcb25c Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDiscussionWithoutSinglePost = errors.New("a Discussion must be created with a single Post")
View Source
var ErrEmptyContent = errors.New("empty Content not allowed")
View Source
var ErrEmptyDiscussionID = errors.New("empty DiscussionID not allowed")
View Source
var ErrEmptyName = errors.New("empty Name not allowed")
View Source
var ErrEmptyPassword = errors.New("empty Password not allowed")
View Source
var ErrEmptyTitle = errors.New("empty Title not allowed")
View Source
var ErrEmptyTopicID = errors.New("empty TopicID not allowed")
View Source
var ErrEmptyUserID = errors.New("empty UserID/AuthorID not allowed")
View Source
var ErrEmptyUserName = errors.New("empty UserName not allowed")

Functions

func CreateDiscussion

func CreateDiscussion(discussion *Discussion) error

func CreateEmail

func CreateEmail(email *Email) error

func CreateGroup

func CreateGroup(group *Group) error

func CreatePost

func CreatePost(post *Post) error

func CreateTopic

func CreateTopic(topic *Topic) error

func CreateUser

func CreateUser(user *User) error

func Models

func Models() []interface{}

Types

type Discussion

type Discussion struct {
	gorm.Model
	Title    string `gorm:"not null" gorm:"size:128"`
	Author   User   `gorm:"foreignKey:AuthorID"`
	AuthorID uint   `gorm:"not null"`
	Topic    Topic  `gorm:"foreignKey:TopicID"`
	TopicID  uint   `gorm:"not null"`
	Posts    []Post
}

type Email

type Email struct {
	Email     string `gorm:"primaryKey" gorm:"size:128"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	User      User           `gorm:"foreignkey:UserID"`
	UserID    uint
}

type Group

type Group struct {
	gorm.Model
	Name     string `gorm:"not null" gorm:"size:64"`
	Users    []User `gorm:"many2many:users_groups;"`
	Author   User   `gorm:"foreignKey:AuthorID"`
	AuthorID uint
}

type Post

type Post struct {
	gorm.Model
	Content      string     `gorm:"size:4096" gorm:"not null"`
	Author       User       `gorm:"foreignKey:AuthorID"`
	AuthorID     uint       `gorm:"not null"`
	Discussion   Discussion `gorm:"foreignKey:DiscussionID"`
	DiscussionID uint       `gorm:"not null"`
}

type Topic

type Topic struct {
	gorm.Model
	Title    string `gorm:"uniqueIndex" gorm:"not null" gorm:"size:96"`
	ParentID *uint  `gorm:"TYPE:integer REFERENCES topics"`
	Parent   *Topic
	Author   User `gorm:"foreignKey:AuthorID"`
	AuthorID uint
}

type User

type User struct {
	gorm.Model
	UserName    string `gorm:"uniqueIndex" gorm:"size:32"`
	DisplayName string `gorm:"not null" gorm:"size:32"`
	Password    string `gorm:"not null" gorm:"size:64"`
	Emails      []Email
	Groups      []Group `gorm:"many2many:users_groups;"`
}

Jump to

Keyboard shortcuts

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