model

package
v0.0.0-...-bbe708f Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2019 License: Unlicense Imports: 3 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 {
	Model
	Text   string `gorm:"type:TEXT" json:"text"`
	Post   Post   `gorm:"foreignkey:Post" json:"post"`
	Author uint   `gorm:"foreignkey:User" json:"author"`
}

func DeleteComment

func DeleteComment(db *gorm.DB, id uint64) (comment Comment, err error)

func GetCommentsByPostId

func GetCommentsByPostId(db *gorm.DB, postid uint64) (comment []Comment, err error)

func (*Comment) Create

func (c *Comment) Create(db *gorm.DB) (err error)

type Like

type Like struct {
	Model
	User   User `gorm:"foreignkey:author"`
	Author uint
}

func (*Like) Create

func (l *Like) Create(db *gorm.DB) (err error)

type Model

type Model struct {
	ID        uint      `gorm:"primary_key" json:"id"`
	CreatedAt time.Time `json:"createdAt ,omitempty"`
	UpdatedAt time.Time `json:"updatedAt ,omitempty"`
	// contains filtered or unexported fields
}

type Post

type Post struct {
	Model
	Title   string `json:"title"`
	Content string `gorm:"type:TEXT" json:"content"`
	User    User   `gorm:"foreignkey:Author" json:"user"`
	Author  uint   `json:"author"`
}

func DeletePost

func DeletePost(db *gorm.DB, id uint64) (post Post, err error)

func FindPostById

func FindPostById(db *gorm.DB, id uint64) (post Post, err error)

func (*Post) Create

func (e *Post) Create(db *gorm.DB) (err error)

type PostResponse

type PostResponse struct {
	ID        uint      `json:"id"`
	Title     string    `json:"title"`
	Content   string    `json:"content"`
	Author    uint      `json:"user"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

func FindPosts

func FindPosts(db *gorm.DB) (posts []PostResponse, err error)

func FindPostsByAuthor

func FindPostsByAuthor(db *gorm.DB, authorid uint64) (post []PostResponse, err error)

type User

type User struct {
	Model
	Name     string `json:"name"`
	Email    string `gorm:"not null;unique" json:"email"`
	Password string `json:"password ,omitempty"`
	Age      int    `json:"age ,omitempty"`
}

func FindUserByEmail

func FindUserByEmail(db *gorm.DB, email string) (user User, err error)

func FindUserById

func FindUserById(db *gorm.DB, id uint64) (user User, err error)

func (*User) Create

func (e *User) Create(db *gorm.DB) (err error)

func (*User) EmailExists

func (e *User) EmailExists(db *gorm.DB) (err error)

type UserResponse

type UserResponse struct {
	ID    uint   `json:"id"`
	Name  string `json:"name"`
	Email string `json:"email"`
	Age   int    `json:"age"`
}

func FindUsers

func FindUsers(db *gorm.DB) (users []UserResponse, err error)

Jump to

Keyboard shortcuts

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