repository

package
v0.0.0-...-d4b65f6 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeDBTables

func MakeDBTables(db *sql.DB) error

MakeDBTables creates necessary database tables using the provided *sql.DB instance. This function helps initialize database tables, and it's intended to be called with a fresh database connection to ensure proper handling for multiple users.

Types

type DataBase

type DataBase struct {
	SQL *sql.DB
}

func GetDB

func GetDB() (*DataBase, error)

GetDB returns a new instance of *DataBase and an error if any. This function allows creating a new connection to the database for each instance of our application, ensuring isolation and proper handling for multiple users.

type DatabaseInt

type DatabaseInt interface {
	UserPresent(userName, email string) (bool, error)
	UserPresentLogin(email, password string) (int, error)
	CreateUser(r models.User) error
	CreateThread(thread models.Thread) (int64, error)
	CreatePost(post models.Post) error
	IsThreadExist(thread models.Thread) (bool, error)
	GetAllPostsFromThread(threadID int) ([]models.Post, error)
	GetUserByID(ID int) (models.User, error)
	GetAllThreads() ([]models.Thread, error)
	GetThreadByID(ID int) (models.Thread, error)
	GetSessionIDForUserID(userID int) (string, error)
	GetUserIDForSessionID(sessionID string) (int, error)
	InsertSessionintoDB(sessionID string, userID int) error
	GetTotalPostsAmmountByUserID(userID int) (int, error)
	LikePostByUserIdAndPostId(userID, postID int) error
	DislikePostByUserIdAndPostId(userID, postID int) error
	CountLikesAndDislikesForPostByPostID(postID int) (likes, dislikes int, err error)
	GetGuestID() (int, error)
	GetSearchedThreads(search string) ([]models.Thread, error)
	GetPostByID(ID int) (models.Post, error)
	EditPost(post models.Post) error
	EditTopic(topic models.Thread) error
	DeletePost(post models.Post) error
	GetSearchedThreadsByCategory(search string) ([]models.Thread, error)
	GetAllThreadsByUserID(userID int) ([]models.Thread, error)
	GetAllPostsByUserID(userID int) ([]models.Post, error)
	GetAllLikedPostsByUserID(userID int) ([]models.Post, error)
	EditUserType(user models.User) error
	DelSessionByUserID(userID int) error
	EditPostClassification(post models.Post, classification models.TextClassification) error
	EditTopicClassification(topic models.Thread, classification models.TextClassification) error
	GetAllPostsByClassification(classification models.TextClassification) ([]models.Post, error)
	GetAllThreadsByClassification(classification models.TextClassification) ([]models.Thread, error)
	CreatePM(pm models.PM) error
	DeletePM(pm models.PM) error
	GetPMbyReceiverUserID(userID int) ([]models.PM, error)
	GetPMbysenderUserID(userID int) ([]models.PM, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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