models

package
v0.0.0-...-6d276ba Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateComment

func CreateComment(joke_id uint, c *CommentRequest) error

func CreateJoke

func CreateJoke(j *JokeRequest) error

func DeleteComment

func DeleteComment(id uint) error

func DeleteJokeById

func DeleteJokeById(id uint) error

func DeleteUserByName

func DeleteUserByName(name string) error

func FetchAllComments

func FetchAllComments(joke_id uint) (*[]CommentRequest, error)

func FetchAllJokes

func FetchAllJokes(limit int, page int, sort string) (*[]JokeRequest, uint, error)

func FetchJokesByAuthor

func FetchJokesByAuthor(author string) (*[]JokeRequest, error)

func FetchTopRatedJokes

func FetchTopRatedJokes(limit int) (*[]JokeRequest, error)

func LoginUser

func LoginUser(u *User) error

func RegisterUser

func RegisterUser(u *User) error

func UpdateComment

func UpdateComment(id uint, c *CommentRequest) error

func UpdateJoke

func UpdateJoke(id uint, j *JokeRequest) error

Types

type Comment

type Comment struct {
	ID       uint   `gorm:"primaryKey"`
	Content  string `gorm:"not null"`
	JokeID   uint
	AuthorID uint
	Author   User
}

type CommentRequest

type CommentRequest struct {
	ID      uint   `json:"id"`
	Content string `json:"content"`
	Author  string `json:"author"`
}

func FetchCommentById

func FetchCommentById(id uint) (*CommentRequest, error)

type Joke

type Joke struct {
	ID       uint   `gorm:"primaryKey"`
	Content  string `gorm:"not null"`
	Rating   uint   `gorm:"default=0"`
	AuthorID uint
	Author   User
	Comments []Comment
}

type JokeRequest

type JokeRequest struct {
	ID      uint   `json:"id"`
	Content string `json:"content"`
	Author  string `json:"author"`
	Rating  uint   `json:"rating"`
}

func FetchAJoke

func FetchAJoke(id uint) (*JokeRequest, error)

func FetchRandomJoke

func FetchRandomJoke() (*JokeRequest, error)

func RateJoke

func RateJoke(id uint, rating uint) (*JokeRequest, error)

type User

type User struct {
	ID       uint   `gorm:"primaryKey" json:"id"`
	Username string `gorm:"unique; not null" json:"username"`
	Password string `gorm:"not null" json:"password,omitempty"`
	Jokes    []Joke `gorm:"foreignKey:AuthorID"`
}

Jump to

Keyboard shortcuts

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