quora

package
v0.0.0-...-37fe33f Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Answer

type Answer struct {
	ID         uint `gorm:"primary_key"`
	Body       string
	UserID     uint
	QuestionID uint
	Timestamp  time.Time
	Votes      []Vote
	Comments   []Comment
}

Answer struct to hold answer data

type Comment

type Comment struct {
	ID         uint `gorm:"primary_key"`
	Body       string
	UserID     uint
	QuestionID uint
	AnswerID   uint
	Timestamp  time.Time
}

Comment struct to hold comment data

type Question

type Question struct {
	ID        uint `gorm:"primary_key"`
	Title     string
	Body      string
	UserID    uint
	Timestamp time.Time
	Answers   []Answer
	Votes     []Vote
	Comments  []Comment
}

Question struct to hold question data

type Quora

type Quora struct {
	DB *gorm.DB
}

Quora struct to hold the database connection

func NewQuora

func NewQuora(connString string) (*Quora, error)

NewQuora returns a new Quora struct with a database connection

func (*Quora) AnswerQuestion

func (q *Quora) AnswerQuestion(userID, questionID uint, body string) (*Answer, error)

AnswerQuestion adds a new answer to a question

func (*Quora) AskQuestion

func (q *Quora) AskQuestion(userID uint, title, body string) (*Question, error)

AskQuestion adds a new question to the platform

func (*Quora) CommentOnQuestion

func (q *Quora) CommentOnQuestion(userID, questionID uint, body string) (*Comment, error)

CommentOnQuestion adds a comment on a question

func (*Quora) DownvoteQuestion

func (q *Quora) DownvoteQuestion(userID, questionID uint) error

DownvoteQuestion downvotes a question

func (*Quora) SearchQuestions

func (q *Quora) SearchQuestions(keyword string) ([]Question, error)

SearchQuestions searches for questions by keyword

func (*Quora) UpvoteQuestion

func (q *Quora) UpvoteQuestion(userID, questionID uint) error

UpvoteQuestion upvotes a question

type Topic

type Topic struct {
	ID          uint `gorm:"primary_key"`
	Name        string
	Description string
	Questions   []Question
}

Topic struct to hold topic data

type User

type User struct {
	ID       uint `gorm:"primary_key"`
	Username string
	Email    string
	Password string
}

User struct to hold user data

type Vote

type Vote struct {
	ID         uint `gorm:"primary_key"`
	UserID     uint
	QuestionID uint
	AnswerID   uint
	Value      int
}

Jump to

Keyboard shortcuts

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