models

package
v0.0.0-...-3a281b6 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2020 License: CC0-1.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	UserID    uint32    `gorm:"not null" json:"user_id"`
	PostID    uint64    `gorm:"not null" json:"post_id"`
	Body      string    `gorm:"text;not null;" json:"body"`
	User      User      `json:"user"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*Comment) DeleteAComment

func (c *Comment) DeleteAComment(db *gorm.DB) (int64, error)

func (*Comment) DeletePostComments

func (c *Comment) DeletePostComments(db *gorm.DB, pid uint64) (int64, error)

When a post is deleted, we also delete the comments that the post had

func (*Comment) DeleteUserComments

func (c *Comment) DeleteUserComments(db *gorm.DB, uid uint32) (int64, error)

When a user is deleted, we also delete the comments that the user had

func (*Comment) GetComments

func (c *Comment) GetComments(db *gorm.DB, pid uint64) (*[]Comment, error)

func (*Comment) Prepare

func (c *Comment) Prepare()

func (*Comment) SaveComment

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

func (*Comment) UpdateAComment

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

func (*Comment) Validate

func (c *Comment) Validate(action string) map[string]string

type Like

type Like struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	UserID    uint32    `gorm:"not null" json:"user_id"`
	PostID    uint64    `gorm:"not null" json:"post_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*Like) DeleteLike

func (l *Like) DeleteLike(db *gorm.DB) (*Like, error)

func (*Like) DeletePostLikes

func (l *Like) DeletePostLikes(db *gorm.DB, pid uint64) (int64, error)

When a post is deleted, we also delete the likes that the post had

func (*Like) DeleteUserLikes

func (l *Like) DeleteUserLikes(db *gorm.DB, uid uint32) (int64, error)

When a post is deleted, we also delete the likes that the post had

func (*Like) GetLikesInfo

func (l *Like) GetLikesInfo(db *gorm.DB, pid uint64) (*[]Like, error)

func (*Like) SaveLike

func (l *Like) SaveLike(db *gorm.DB) (*Like, error)

type Post

type Post struct {
	ID        uint64    `gorm:"primary_key;auto_increment" json:"id"`
	Title     string    `gorm:"size:255;not null;unique" json:"title"`
	Content   string    `gorm:"text;not null;" json:"content"`
	Author    User      `json:"author"`
	AuthorID  uint32    `gorm:"not null" json:"author_id"`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*Post) DeleteAPost

func (p *Post) DeleteAPost(db *gorm.DB) (int64, error)

func (*Post) DeleteUserPosts

func (c *Post) DeleteUserPosts(db *gorm.DB, uid uint32) (int64, error)

When a user is deleted, we also delete the post that the user had

func (*Post) FindAllPosts

func (p *Post) FindAllPosts(db *gorm.DB) (*[]Post, error)

func (*Post) FindPostByID

func (p *Post) FindPostByID(db *gorm.DB, pid uint64) (*Post, error)

func (*Post) FindUserPosts

func (p *Post) FindUserPosts(db *gorm.DB, uid uint32) (*[]Post, error)

func (*Post) Prepare

func (p *Post) Prepare()

func (*Post) SavePost

func (p *Post) SavePost(db *gorm.DB) (*Post, error)

func (*Post) UpdateAPost

func (p *Post) UpdateAPost(db *gorm.DB) (*Post, error)

func (*Post) Validate

func (p *Post) Validate() map[string]string

type ResetPassword

type ResetPassword struct {
	gorm.Model
	Email string `gorm:"size:100;not null;" json:"email"`
	Token string `gorm:"size:255;not null;" json:"token"`
}

func (*ResetPassword) DeleteDatails

func (resetPassword *ResetPassword) DeleteDatails(db *gorm.DB) (int64, error)

func (*ResetPassword) Prepare

func (resetPassword *ResetPassword) Prepare()

func (*ResetPassword) SaveDatails

func (resetPassword *ResetPassword) SaveDatails(db *gorm.DB) (*ResetPassword, error)

type User

type User struct {
	ID         uint32    `gorm:"primary_key;auto_increment" json:"id"`
	Username   string    `gorm:"size:255;not null;unique" json:"username"`
	Email      string    `gorm:"size:100;not null;unique" json:"email"`
	Password   string    `gorm:"size:100;not null;" json:"password"`
	AvatarPath string    `gorm:"size:255;null;" json:"avatar_path"`
	CreatedAt  time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"created_at"`
	UpdatedAt  time.Time `gorm:"default:CURRENT_TIMESTAMP" json:"updated_at"`
}

func (*User) AfterFind

func (u *User) AfterFind() (err error)

func (*User) BeforeSave

func (u *User) BeforeSave() error

func (*User) DeleteAUser

func (u *User) DeleteAUser(db *gorm.DB, uid uint32) (int64, error)

func (*User) FindAllUsers

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

THE ONLY PERSON THAT NEED TO DO THIS IS THE ADMIN, SO I HAVE COMMENTED THE ROUTES, SO SOMEONE ELSE DONT VIEW THIS DETAILS.

func (*User) FindUserByID

func (u *User) FindUserByID(db *gorm.DB, uid uint32) (*User, error)

func (*User) Prepare

func (u *User) Prepare()

func (*User) SaveUser

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

func (*User) UpdateAUser

func (u *User) UpdateAUser(db *gorm.DB, uid uint32) (*User, error)

func (*User) UpdateAUserAvatar

func (u *User) UpdateAUserAvatar(db *gorm.DB, uid uint32) (*User, error)

func (*User) UpdatePassword

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

func (*User) Validate

func (u *User) Validate(action string) map[string]string

Jump to

Keyboard shortcuts

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