models

package
v0.0.0-...-4b8811d Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2021 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action struct {
	ID   uint `gorm:"primaryKey,autoIncrement"`
	Name string
}

type Comment

type Comment struct {
	ID              uint      `gorm:"primaryKey,autoincrement" json:"id"`
	Author          User      `gorm:"foreignKey:AuthorID" json:"author"`
	AuthorID        uint      `json:"-"`
	TopicID         uint      `json:"topic_id"`
	Content         string    `json:"content"`
	CreatedAt       time.Time `json:"created_at"`
	ParentComment   *Comment  `gorm:"foreignKey:ParentCommentId" json:"parent_comment"`
	ParentCommentId uint      `json:"parent_comment_id"`
	Votes           int       `json:"votes"`
}

type Topic

type Topic struct {
	ID            uint      `gorm:"primaryKey" json:"id"`
	AuthorID      uint      `json:"-"`
	Author        User      `json:"author"`
	Title         string    `json:"title"`
	Body          string    `json:"body"`
	CreatedAt     time.Time `json:"createdAt"`
	Likes         uint      `gorm:"-" json:"likes"`
	Liked         bool      `gorm:"-" json:"liked"`
	TopicActions  []Action  `gorm:"many2many:topic_actions;" json:"-"`
	Comments      []Comment `gorm:"foreignKey:TopicID" json:"comments,omitempty"`
	CommentsCount uint      `gorm:"-" json:"commentsCount"`
}

type TopicAction

type TopicAction struct {
	ID        uint   `gorm:"primaryKey,autoincrement"`
	UserID    uint   `gorm:"uniqueIndex:idx_topic_action"`
	TopicID   uint   `gorm:"uniqueIndex:idx_topic_action"`
	ActionID  uint   `gorm:"uniqueIndex:idx_topic_action"`
	Action    Action `gorm:"foreignKey:ActionID"`
	CreatedAt time.Time
}

type User

type User struct {
	ID        uint      `gorm:"primaryKey,autoIncrement" json:"id"`
	Username  string    `gorm:"index" json:"username"`
	GivenName string    `json:"givenName"`
	LastName  string    `json:"lastName"`
	Admin     bool      `gorm:"index" json:"admin"`
	CreatedAt time.Time `json:"createdAt"`
	LastLogin time.Time `json:"-"`
	Deleted   bool      `gorm:"index" json:"-"`

	UserDetails UserDetails `gorm:"foreignKey:ID" json:"details,omitempty"`
}

type UserDetails

type UserDetails struct {
	ID         uint   `gorm:"primaryKey,autoincrement" json:"-"`
	Department string `gorm:"index" json:"department,omitempty"`
	Email      string `json:"email,omitempty"`
}

Jump to

Keyboard shortcuts

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