models

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

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

Go to latest
Published: Nov 2, 2026 License: GPL-3.0 Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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