Documentation
¶
Overview ¶
Package db handles all database intercations of the server
Index ¶
- Variables
- func BoardCounter(board string) (counter uint64, err error)
- func CreateIndeces() error
- func CreateTables() error
- func DB() func(r.Term) DatabaseHelper
- func LoadDB() (err error)
- func PostCounter() (counter uint64, err error)
- func ThreadCounter(id uint64) (counter uint64, err error)
- func ValidateOP(id uint64, board string) (valid bool, err error)
- type DatabaseHelper
- type Document
- type Reader
Constants ¶
This section is empty.
Variables ¶
var AllTables = [...]string{"main", "threads", "posts"}
AllTables are all tables needed for meguca operation
var RSession *r.Session
RSession exports the RethinkDB connection session. Used globally by the entire server.
Functions ¶
func BoardCounter ¶
BoardCounter retrieves the history or "progress" counter of a board
func CreateIndeces ¶
func CreateIndeces() error
CreateIndeces create secondary indeces for faster table queries
func CreateTables ¶
func CreateTables() error
CreateTables creates all tables needed for meguca operation
func DB ¶
func DB() func(r.Term) DatabaseHelper
DB returns a function that creates a new DatabaseHelper. Used to simplify database queries. Simply DB()(${query}).${method}() Example: err := DB()(r.Table("posts").Get(1)).One(&Post)
func LoadDB ¶
func LoadDB() (err error)
LoadDB establishes connections to RethinkDB and Redis and bootstraps both databases, if not yet done.
func PostCounter ¶
PostCounter retrieves the current post counter number
func ThreadCounter ¶
ThreadCounter retrieve the history or "progress" counter of a thread
Types ¶
type DatabaseHelper ¶
type DatabaseHelper struct {
// contains filtered or unexported fields
}
DatabaseHelper simplifies managing queries, by providing extra utility
func (DatabaseHelper) All ¶
func (d DatabaseHelper) All(res interface{}) error
All writes all responses into target pointer to slice or returns error
func (DatabaseHelper) Exec ¶
func (d DatabaseHelper) Exec() error
Exec excutes the inner query and only returns an error, if any
func (DatabaseHelper) One ¶
func (d DatabaseHelper) One(res interface{}) error
One writes the query result into the target pointer or throws an error
type Document ¶
type Document struct {
ID string `gorethink:"id"`
}
Document is a eneric RethinkDB Document. For DRY-ness.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader reads on formats thread, post and board structs
func (*Reader) GetAllBoard ¶
GetAllBoard retrieves all threads the client has access to for the "/all/" meta-board