...

Package database

Overview ▾

Package database provides methods for interacting with a Sriracha database.

Index ▾

Constants
func Connect(c *Config) (*pgxpool.Pool, error)
type DB
    func Begin(pool *pgxpool.Pool, config *Config) *DB
    func (db *DB) AccountByID(id int) *Account
    func (db *DB) AccountBySessionKey(sessionKey string) *Account
    func (db *DB) AccountByUsername(username string) *Account
    func (db *DB) AddAccount(a *Account, password string)
    func (db *DB) AddBan(b *Ban)
    func (db *DB) AddBanner(b *Banner)
    func (db *DB) AddBoard(b *Board)
    func (db *DB) AddCAPTCHA(c *CAPTCHA)
    func (db *DB) AddFileBan(fileHash string)
    func (db *DB) AddKeyword(k *Keyword)
    func (db *DB) AddLog(l *Log)
    func (db *DB) AddNews(n *News)
    func (db *DB) AddPage(p *Page)
    func (db *DB) AddPost(p *Post)
    func (db *DB) AddReport(r *Report)
    func (db *DB) AddSubscription(s *Subscription)
    func (db *DB) AllAccounts() []*Account
    func (db *DB) AllBanners() []*Banner
    func (db *DB) AllBans(rangeOnly bool) []*Ban
    func (db *DB) AllBoards() []*Board
    func (db *DB) AllKeywords() []*Keyword
    func (db *DB) AllNews(onlyPublished bool) []*News
    func (db *DB) AllPages() []*Page
    func (db *DB) AllPostsInThread(postID int, moderated bool) []*Post
    func (db *DB) AllReplies(threadID int, limit int, moderated bool) []*Post
    func (db *DB) AllReports() []*Report
    func (db *DB) AllThreads(board *Board, moderated bool) [][2]int
    func (db *DB) BanByID(id int) *Ban
    func (db *DB) BanByIP(ip string) *Ban
    func (db *DB) BannerByID(id int) *Banner
    func (db *DB) BannerByName(name string) *Banner
    func (db *DB) BoardByDir(dir string) *Board
    func (db *DB) BoardByID(id int) *Board
    func (db *DB) BumpThread(threadID int, timestamp int64)
    func (db *DB) Commit()
    func (db *DB) CommitWithErr() error
    func (db *DB) DeleteBan(id int)
    func (db *DB) DeleteBanner(id int)
    func (db *DB) DeleteBoard(id int)
    func (db *DB) DeleteCAPTCHA(ip string)
    func (db *DB) DeleteExpiredBans() int
    func (db *DB) DeleteExpiredSubscriptions() int
    func (db *DB) DeleteKeyword(id int)
    func (db *DB) DeleteNews(id int)
    func (db *DB) DeletePage(id int)
    func (db *DB) DeletePost(postID int)
    func (db *DB) DeleteReports(p *Post)
    func (db *DB) DeleteSubscription(s *Subscription)
    func (db *DB) DeleteSubscriptionsByBoard(boardID int)
    func (db *DB) DeleteSubscriptionsByPost(postID int)
    func (db *DB) Exec(sql string, arguments ...any) (pgconn.CommandTag, error)
    func (db *DB) ExpiredCAPTCHAs() []*CAPTCHA
    func (db *DB) FileBanned(fileHash string) bool
    func (db *DB) GetBool(key string) bool
    func (db *DB) GetCAPTCHA(ip string) *CAPTCHA
    func (db *DB) GetFloat(key string) float64
    func (db *DB) GetInt(key string) int
    func (db *DB) GetInt64(key string) int64
    func (db *DB) GetMultiInt(key string) []int
    func (db *DB) GetMultiString(key string) []string
    func (db *DB) GetString(key string) string
    func (db *DB) HaveConfig(key string) bool
    func (db *DB) KeywordByID(id int) *Keyword
    func (db *DB) KeywordByText(text string) *Keyword
    func (db *DB) LastPostByIP(board *Board, ip string) *Post
    func (db *DB) LiftFileBan(fileHash string)
    func (db *DB) LockPost(postID int, lock bool)
    func (db *DB) LogCount() int
    func (db *DB) LoginAccount(username string, password string) *Account
    func (db *DB) LogsByPage(page int) []*Log
    func (db *DB) ModeratePost(postID int, moderated PostModerated)
    func (db *DB) NewCAPTCHAImage() string
    func (db *DB) NewsByID(id int) *News
    func (db *DB) NumReports(p *Post) int
    func (db *DB) PageByID(id int) *Page
    func (db *DB) PageByPath(path string) *Page
    func (db *DB) PendingPosts() []*Post
    func (db *DB) PostByField(b *Board, field string, value any) *Post
    func (db *DB) PostByID(postID int) *Post
    func (db *DB) PostsByFileHash(hash string, filterBoard *Board) []*Post
    func (db *DB) PostsByIP(hash string) []*Post
    func (db *DB) QueryRow(sql string, arguments ...any) pgx.Row
    func (db *DB) ReplyCount(threadID int) int
    func (db *DB) RollBack()
    func (db *DB) SaveBool(key string, value bool)
    func (db *DB) SaveFloat(key string, value float64)
    func (db *DB) SaveInt(key string, value int)
    func (db *DB) SaveInt64(key string, value int64)
    func (db *DB) SaveMultiInt(key string, values []int)
    func (db *DB) SaveMultiString(key string, value []string)
    func (db *DB) SaveString(key string, value string)
    func (db *DB) SoftRollBack()
    func (db *DB) StickyPost(postID int, sticky bool)
    func (db *DB) SubscriptionByID(id int) *Subscription
    func (db *DB) SubscriptionByIP(ip string) *Subscription
    func (db *DB) SubscriptionsByEmail(email string) []*Subscription
    func (db *DB) SubscriptionsByPost(p *Post, distinct bool, includeBoard bool) []*Subscription
    func (db *DB) TrimThreads(board *Board) []*Post
    func (db *DB) UniqueUserPosts(b *Board) int
    func (db *DB) UpdateAccountLastActive(id int)
    func (db *DB) UpdateAccountLocale(id int, locale string)
    func (db *DB) UpdateAccountPassword(id int, password string)
    func (db *DB) UpdateAccountRole(a *Account)
    func (db *DB) UpdateAccountStyle(id int, style string)
    func (db *DB) UpdateAccountUsername(a *Account)
    func (db *DB) UpdateBan(b *Ban)
    func (db *DB) UpdateBanner(b *Banner)
    func (db *DB) UpdateBoard(b *Board)
    func (db *DB) UpdateCAPTCHA(c *CAPTCHA)
    func (db *DB) UpdateKeyword(k *Keyword)
    func (db *DB) UpdateNews(n *News)
    func (db *DB) UpdatePage(p *Page)
    func (db *DB) UpdatePostBoard(postID int, boardID int)
    func (db *DB) UpdatePostMessage(postID int, message string)
    func (db *DB) UpdatePostNameblock(postID int, nameblock string)
    func (db *DB) UpdateSubscription(s *Subscription)

Package files

database.go database_account.go database_ban.go database_banner.go database_board.go database_captcha.go database_keyword.go database_log.go database_news.go database_page.go database_post.go database_report.go database_schema.go database_subscription.go

Constants

const LogPageSize = 25

func Connect

func Connect(c *Config) (*pgxpool.Pool, error)

type DB

DB represents a database connection.

type DB struct {
    Plugin string
    // contains filtered or unexported fields
}

func Begin

func Begin(pool *pgxpool.Pool, config *Config) *DB

func (*DB) AccountByID

func (db *DB) AccountByID(id int) *Account

func (*DB) AccountBySessionKey

func (db *DB) AccountBySessionKey(sessionKey string) *Account

func (*DB) AccountByUsername

func (db *DB) AccountByUsername(username string) *Account

func (*DB) AddAccount

func (db *DB) AddAccount(a *Account, password string)

func (*DB) AddBan

func (db *DB) AddBan(b *Ban)

func (*DB) AddBanner

func (db *DB) AddBanner(b *Banner)

func (*DB) AddBoard

func (db *DB) AddBoard(b *Board)

func (*DB) AddCAPTCHA

func (db *DB) AddCAPTCHA(c *CAPTCHA)

func (*DB) AddFileBan

func (db *DB) AddFileBan(fileHash string)

func (*DB) AddKeyword

func (db *DB) AddKeyword(k *Keyword)

func (*DB) AddLog

func (db *DB) AddLog(l *Log)

func (*DB) AddNews

func (db *DB) AddNews(n *News)

func (*DB) AddPage

func (db *DB) AddPage(p *Page)

func (*DB) AddPost

func (db *DB) AddPost(p *Post)

func (*DB) AddReport

func (db *DB) AddReport(r *Report)

func (*DB) AddSubscription

func (db *DB) AddSubscription(s *Subscription)

func (*DB) AllAccounts

func (db *DB) AllAccounts() []*Account

func (*DB) AllBanners

func (db *DB) AllBanners() []*Banner

func (*DB) AllBans

func (db *DB) AllBans(rangeOnly bool) []*Ban

func (*DB) AllBoards

func (db *DB) AllBoards() []*Board

func (*DB) AllKeywords

func (db *DB) AllKeywords() []*Keyword

func (*DB) AllNews

func (db *DB) AllNews(onlyPublished bool) []*News

func (*DB) AllPages

func (db *DB) AllPages() []*Page

func (*DB) AllPostsInThread

func (db *DB) AllPostsInThread(postID int, moderated bool) []*Post

func (*DB) AllReplies

func (db *DB) AllReplies(threadID int, limit int, moderated bool) []*Post

func (*DB) AllReports

func (db *DB) AllReports() []*Report

func (*DB) AllThreads

func (db *DB) AllThreads(board *Board, moderated bool) [][2]int

AllThreads returns all thread IDs and reply counts. When board is nil, only threads belonging to boards included in the overboard are returned.

func (*DB) BanByID

func (db *DB) BanByID(id int) *Ban

func (*DB) BanByIP

func (db *DB) BanByIP(ip string) *Ban

func (*DB) BannerByID

func (db *DB) BannerByID(id int) *Banner

func (*DB) BannerByName

func (db *DB) BannerByName(name string) *Banner

func (*DB) BoardByDir

func (db *DB) BoardByDir(dir string) *Board

func (*DB) BoardByID

func (db *DB) BoardByID(id int) *Board

func (*DB) BumpThread

func (db *DB) BumpThread(threadID int, timestamp int64)

func (*DB) Commit

func (db *DB) Commit()

func (*DB) CommitWithErr

func (db *DB) CommitWithErr() error

func (*DB) DeleteBan

func (db *DB) DeleteBan(id int)

func (*DB) DeleteBanner

func (db *DB) DeleteBanner(id int)

func (*DB) DeleteBoard

func (db *DB) DeleteBoard(id int)

func (*DB) DeleteCAPTCHA

func (db *DB) DeleteCAPTCHA(ip string)

func (*DB) DeleteExpiredBans

func (db *DB) DeleteExpiredBans() int

func (*DB) DeleteExpiredSubscriptions

func (db *DB) DeleteExpiredSubscriptions() int

func (*DB) DeleteKeyword

func (db *DB) DeleteKeyword(id int)

func (*DB) DeleteNews

func (db *DB) DeleteNews(id int)

func (*DB) DeletePage

func (db *DB) DeletePage(id int)

func (*DB) DeletePost

func (db *DB) DeletePost(postID int)

func (*DB) DeleteReports

func (db *DB) DeleteReports(p *Post)

func (*DB) DeleteSubscription

func (db *DB) DeleteSubscription(s *Subscription)

func (*DB) DeleteSubscriptionsByBoard

func (db *DB) DeleteSubscriptionsByBoard(boardID int)

func (*DB) DeleteSubscriptionsByPost

func (db *DB) DeleteSubscriptionsByPost(postID int)

func (*DB) Exec

func (db *DB) Exec(sql string, arguments ...any) (pgconn.CommandTag, error)

func (*DB) ExpiredCAPTCHAs

func (db *DB) ExpiredCAPTCHAs() []*CAPTCHA

func (*DB) FileBanned

func (db *DB) FileBanned(fileHash string) bool

func (*DB) GetBool

func (db *DB) GetBool(key string) bool

func (*DB) GetCAPTCHA

func (db *DB) GetCAPTCHA(ip string) *CAPTCHA

func (*DB) GetFloat

func (db *DB) GetFloat(key string) float64

func (*DB) GetInt

func (db *DB) GetInt(key string) int

func (*DB) GetInt64

func (db *DB) GetInt64(key string) int64

func (*DB) GetMultiInt

func (db *DB) GetMultiInt(key string) []int

func (*DB) GetMultiString

func (db *DB) GetMultiString(key string) []string

func (*DB) GetString

func (db *DB) GetString(key string) string

func (*DB) HaveConfig

func (db *DB) HaveConfig(key string) bool

func (*DB) KeywordByID

func (db *DB) KeywordByID(id int) *Keyword

func (*DB) KeywordByText

func (db *DB) KeywordByText(text string) *Keyword

func (*DB) LastPostByIP

func (db *DB) LastPostByIP(board *Board, ip string) *Post

func (*DB) LiftFileBan

func (db *DB) LiftFileBan(fileHash string)

func (*DB) LockPost

func (db *DB) LockPost(postID int, lock bool)

func (*DB) LogCount

func (db *DB) LogCount() int

func (*DB) LoginAccount

func (db *DB) LoginAccount(username string, password string) *Account

func (*DB) LogsByPage

func (db *DB) LogsByPage(page int) []*Log

func (*DB) ModeratePost

func (db *DB) ModeratePost(postID int, moderated PostModerated)

func (*DB) NewCAPTCHAImage

func (db *DB) NewCAPTCHAImage() string

func (*DB) NewsByID

func (db *DB) NewsByID(id int) *News

func (*DB) NumReports

func (db *DB) NumReports(p *Post) int

func (*DB) PageByID

func (db *DB) PageByID(id int) *Page

func (*DB) PageByPath

func (db *DB) PageByPath(path string) *Page

func (*DB) PendingPosts

func (db *DB) PendingPosts() []*Post

func (*DB) PostByField

func (db *DB) PostByField(b *Board, field string, value any) *Post

func (*DB) PostByID

func (db *DB) PostByID(postID int) *Post

func (*DB) PostsByFileHash

func (db *DB) PostsByFileHash(hash string, filterBoard *Board) []*Post

func (*DB) PostsByIP

func (db *DB) PostsByIP(hash string) []*Post

func (*DB) QueryRow

func (db *DB) QueryRow(sql string, arguments ...any) pgx.Row

func (*DB) ReplyCount

func (db *DB) ReplyCount(threadID int) int

func (*DB) RollBack

func (db *DB) RollBack()

func (*DB) SaveBool

func (db *DB) SaveBool(key string, value bool)

func (*DB) SaveFloat

func (db *DB) SaveFloat(key string, value float64)

func (*DB) SaveInt

func (db *DB) SaveInt(key string, value int)

func (*DB) SaveInt64

func (db *DB) SaveInt64(key string, value int64)

func (*DB) SaveMultiInt

func (db *DB) SaveMultiInt(key string, values []int)

func (*DB) SaveMultiString

func (db *DB) SaveMultiString(key string, value []string)

func (*DB) SaveString

func (db *DB) SaveString(key string, value string)

func (*DB) SoftRollBack

func (db *DB) SoftRollBack()

func (*DB) StickyPost

func (db *DB) StickyPost(postID int, sticky bool)

func (*DB) SubscriptionByID

func (db *DB) SubscriptionByID(id int) *Subscription

func (*DB) SubscriptionByIP

func (db *DB) SubscriptionByIP(ip string) *Subscription

func (*DB) SubscriptionsByEmail

func (db *DB) SubscriptionsByEmail(email string) []*Subscription

func (*DB) SubscriptionsByPost

func (db *DB) SubscriptionsByPost(p *Post, distinct bool, includeBoard bool) []*Subscription

func (*DB) TrimThreads

func (db *DB) TrimThreads(board *Board) []*Post

func (*DB) UniqueUserPosts

func (db *DB) UniqueUserPosts(b *Board) int

func (*DB) UpdateAccountLastActive

func (db *DB) UpdateAccountLastActive(id int)

func (*DB) UpdateAccountLocale

func (db *DB) UpdateAccountLocale(id int, locale string)

func (*DB) UpdateAccountPassword

func (db *DB) UpdateAccountPassword(id int, password string)

func (*DB) UpdateAccountRole

func (db *DB) UpdateAccountRole(a *Account)

func (*DB) UpdateAccountStyle

func (db *DB) UpdateAccountStyle(id int, style string)

func (*DB) UpdateAccountUsername

func (db *DB) UpdateAccountUsername(a *Account)

func (*DB) UpdateBan

func (db *DB) UpdateBan(b *Ban)

func (*DB) UpdateBanner

func (db *DB) UpdateBanner(b *Banner)

func (*DB) UpdateBoard

func (db *DB) UpdateBoard(b *Board)

func (*DB) UpdateCAPTCHA

func (db *DB) UpdateCAPTCHA(c *CAPTCHA)

func (*DB) UpdateKeyword

func (db *DB) UpdateKeyword(k *Keyword)

func (*DB) UpdateNews

func (db *DB) UpdateNews(n *News)

func (*DB) UpdatePage

func (db *DB) UpdatePage(p *Page)

func (*DB) UpdatePostBoard

func (db *DB) UpdatePostBoard(postID int, boardID int)

func (*DB) UpdatePostMessage

func (db *DB) UpdatePostMessage(postID int, message string)

func (*DB) UpdatePostNameblock

func (db *DB) UpdatePostNameblock(postID int, nameblock string)

func (*DB) UpdateSubscription

func (db *DB) UpdateSubscription(s *Subscription)