controller

package
v0.0.0-...-c37b867 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: GPL-2.0, GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

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

Jump to

Keyboard shortcuts

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