services

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

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

Go to latest
Published: Jan 11, 2019 License: MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeConnectionConfig

func MakeConnectionConfig(config Config) pgx.ConnConfig

Types

type Config

type Config struct {
	// Address that locates our postgres instance
	Host string
	// Port to connect to
	Port uint16
	// User that has access to the database
	User string
	// Password so that the user can login
	Password string
	// Database to connect to (must have been created priorly)
	DBName string
}

type Database

type Database interface {
	Setup(string)
	Execute(string)
	Result()
	Close()
	Query(string)
	QueryRow(query string, args ...interface{})
}

type ForumService

type ForumService struct {
	// contains filtered or unexported fields
}

func MakeForumService

func MakeForumService(pgdb *PostgresDatabase) ForumService

func (*ForumService) AddForum

func (fs *ForumService) AddForum(forum *models.Forum) (bool, *models.Forum)

func (*ForumService) AddUsers

func (fs *ForumService) AddUsers(nicknames []string, forumSlug string)

func (*ForumService) GetForumBySlug

func (fs *ForumService) GetForumBySlug(slug string) *models.Forum

func (*ForumService) GetUsers

func (fs *ForumService) GetUsers(forum *models.Forum, since, limit string, desc bool) []models.User

func (*ForumService) IncThreadsCountBySlug

func (fs *ForumService) IncThreadsCountBySlug(slug string) bool

func (*ForumService) IncrementPostsCountBySlug

func (fs *ForumService) IncrementPostsCountBySlug(forumSlug string, postsCount int)

func (*ForumService) SlugBySlug

func (fs *ForumService) SlugBySlug(slug string) *string

func (*ForumService) TableName

func (fs *ForumService) TableName() string

type ParentThread

type ParentThread struct {
	ParentID uint64
	Thread   uint64
}

type PostService

type PostService struct {
	// contains filtered or unexported fields
}

func MakePostService

func MakePostService(pgdb *PostgresDatabase) PostService

func (*PostService) AddSomePosts

func (ps *PostService) AddSomePosts(posts models.PostsArray, requiredParents []uint64) (bool, models.PostsArray)

func (*PostService) GetPostById

func (ps *PostService) GetPostById(id uint64) *models.Post

func (*PostService) GetPostsFlat

func (ps *PostService) GetPostsFlat(thread *models.Thread, limit, since string, desc bool) []models.Post

func (*PostService) GetPostsParentTreeSort

func (ps *PostService) GetPostsParentTreeSort(thread *models.Thread, limit, since string, desc bool) []models.Post

func (*PostService) GetPostsTreeSort

func (ps *PostService) GetPostsTreeSort(thread *models.Thread, limit, since string, desc bool) []models.Post

func (*PostService) RequiredParents

func (ps *PostService) RequiredParents(posts []models.Post) []uint64

func (*PostService) TableName

func (ps *PostService) TableName() string

func (*PostService) UpdatePost

func (ps *PostService) UpdatePost(post *models.Post) *models.Post

type PostgresDatabase

type PostgresDatabase struct {
	Connections *pgx.ConnPool
}

func Connect

func Connect(connectionConfig pgx.ConnConfig) PostgresDatabase

func (*PostgresDatabase) Close

func (pgdb *PostgresDatabase) Close()

func (*PostgresDatabase) DataBase

func (pgdb *PostgresDatabase) DataBase() *pgx.ConnPool

func (*PostgresDatabase) Execute

func (pgdb *PostgresDatabase) Execute(query string, args ...interface{}) pgx.CommandTag

func (*PostgresDatabase) Query

func (pgdb *PostgresDatabase) Query(query string, args ...interface{}) *pgx.Rows

func (*PostgresDatabase) QueryRow

func (pgdb *PostgresDatabase) QueryRow(query string, args ...interface{}) *pgx.Row

func (*PostgresDatabase) Setup

func (pgdb *PostgresDatabase) Setup(filename string)

type ThreadService

type ThreadService struct {
	// contains filtered or unexported fields
}

func MakeThreadService

func MakeThreadService(pgdb *PostgresDatabase) ThreadService

func (*ThreadService) AddThread

func (ts *ThreadService) AddThread(thread *models.Thread) (bool, *models.Thread)

func (*ThreadService) GetThreadById

func (ts *ThreadService) GetThreadById(id uint64) *models.Thread

func (*ThreadService) GetThreadBySlug

func (ts *ThreadService) GetThreadBySlug(slug string) *models.Thread

func (*ThreadService) GetThreadIDBySlugOrId

func (ts *ThreadService) GetThreadIDBySlugOrId(slugOrID string) (uint64, bool)

func (*ThreadService) SelectThreads

func (ts *ThreadService) SelectThreads(slug, limit, since string, desc bool) (bool, []models.Thread)

func (*ThreadService) TableName

func (ts *ThreadService) TableName() string

func (*ThreadService) UpdateThread

func (ts *ThreadService) UpdateThread(thread *models.Thread) *models.Thread

func (*ThreadService) Vote

func (ts *ThreadService) Vote(thread *models.Thread, vote models.Vote) *models.Thread

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func MakeUserService

func MakeUserService(pgdb *PostgresDatabase) UserService

func (*UserService) AddUser

func (uc *UserService) AddUser(user *models.User) (bool, []models.User)

func (*UserService) GetDB

func (uc *UserService) GetDB() *PostgresDatabase

func (*UserService) GetUserByEmail

func (uc *UserService) GetUserByEmail(email string) *models.User

func (*UserService) GetUserByNickname

func (uc *UserService) GetUserByNickname(nickname string) *models.User

func (*UserService) GetUserIDByNickname

func (uc *UserService) GetUserIDByNickname(nickname string) *string

func (*UserService) GetUsersByEmailOrNick

func (uc *UserService) GetUsersByEmailOrNick(email, nickname string) []models.User

func (*UserService) GetUsersByNicknamesArray

func (uc *UserService) GetUsersByNicknamesArray(nicknames map[string]bool) []string

func (*UserService) TableName

func (us *UserService) TableName() string

func (*UserService) UpdateUser

func (uc *UserService) UpdateUser(user *models.User)

Jump to

Keyboard shortcuts

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