Documentation ¶
Index ¶
- type DbController
- func (dbo *DbController) Clear() bool
- func (dbo *DbController) Init() error
- func (dbo *DbController) InsertHash(hash string) error
- func (dbo *DbController) InsertPost(post tp.Post) error
- func (dbo *DbController) InsertReaction(reaction tp.Reaction) error
- func (dbo *DbController) SelectAnonReactionCount(postId int) (int, error)
- func (dbo *DbController) SelectCandidateHashes() ([5]string, error)
- func (dbo *DbController) SelectDescriptors(postId int) (string, error)
- func (dbo *DbController) SelectLatestTimestamp() (time.Time, error)
- func (dbo *DbController) SelectPostReactionHashes(postId int) ([5]string, error)
- func (dbo *DbController) SelectPostReactions(postId int) ([]tp.Reaction, error)
- func (dbo *DbController) SelectPosts() ([]tp.Post, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DbController ¶
type DbController struct {
// contains filtered or unexported fields
}
Database object is where all queries are executed on
func (*DbController) Clear ¶
func (dbo *DbController) Clear() bool
Clears db, for use in integration tests
func (*DbController) Init ¶
func (dbo *DbController) Init() error
Establishes database connection and sets up tables if needed
Returns an error if applicable
func (*DbController) InsertHash ¶
func (dbo *DbController) InsertHash(hash string) error
Adds a new row to the passcode table, with a generated hash
func (*DbController) InsertPost ¶
func (dbo *DbController) InsertPost(post tp.Post) error
Adds a new post to the blog database. Using user data from the frontend
and a generated descriptors and tag. // Params: Post with the fields title, author, contents, descriptors, tag, codeHash populated // Ensures that all data for a post has been entered
func (*DbController) InsertReaction ¶
func (dbo *DbController) InsertReaction(reaction tp.Reaction) error
Adds a new reaction to db
func (*DbController) SelectAnonReactionCount ¶
func (dbo *DbController) SelectAnonReactionCount(postId int) (int, error)
Selects the number of anonymous reactions (those with gravitas 2) made on
the specified post
func (*DbController) SelectCandidateHashes ¶
func (dbo *DbController) SelectCandidateHashes() ([5]string, error)
Selects the 5 hashes that can be used for post or reaction validation. This
is an array of the form [latest hash, second latest hash, third latest, fourth latest, genesis hash]
func (*DbController) SelectDescriptors ¶
func (dbo *DbController) SelectDescriptors(postId int) (string, error)
Selects the descriptors string from the post with id *postId*
func (*DbController) SelectLatestTimestamp ¶
func (dbo *DbController) SelectLatestTimestamp() (time.Time, error)
Gets the timestamp of the latest post
func (*DbController) SelectPostReactionHashes ¶
func (dbo *DbController) SelectPostReactionHashes( postId int) ([5]string, error)
Selects the reaction hashes associated with a given post
func (*DbController) SelectPostReactions ¶
func (dbo *DbController) SelectPostReactions( postId int) ([]tp.Reaction, error)
Gets Reaction tuples from sqlite grouped by each descriptor. Returns a slice
with an ascending list of such tuples ordered by their total gravitas
func (*DbController) SelectPosts ¶
func (dbo *DbController) SelectPosts() ([]tp.Post, error)
Gets all Post tuples from sqlite