votemodel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteItemVotes

func DeleteItemVotes(db *sql.DB, itemid []byte) *governor.Error

DeleteItemVotes deletes all the votes of an item

func DeletePostVotes

func DeletePostVotes(db *sql.DB, postid []byte) *governor.Error

DeletePostVotes deletes all the votes of a post

func GetScoreByID

func GetScoreByID(db *sql.DB, itemid []byte) (int32, int32, *governor.Error)

GetScoreByID returns the score of an item

func GetScoreByIDB64

func GetScoreByIDB64(db *sql.DB, itemid string) (int32, int32, *governor.Error)

GetScoreByIDB64 returns the score of an item

func ParseB64ToUID

func ParseB64ToUID(idb64 string) (*uid.UID, *governor.Error)

ParseB64ToUID converts a base64 into a UID

func ParseUIDToB64

func ParseUIDToB64(postid []byte) (*uid.UID, *governor.Error)

ParseUIDToB64 converts a UID into base64

func Setup

func Setup(db *sql.DB) *governor.Error

Setup creates a new Post table

Types

type Model

type Model struct {
	ModelInfo
	Postid []byte `json:"postid"`
	Group  string `json:"group"`
	Time   int64  `json:"time"`
}

Model is the db Vote model

func GetByIDB64

func GetByIDB64(db *sql.DB, itemid, userid string) (*Model, *governor.Error)

GetByIDB64 returns a vote model with the given base64 ids

func New

func New(itemid, postid, group, userid string, score int16) (*Model, *governor.Error)

New creates a new Vote Model

func NewDown

func NewDown(itemid, postid, group, userid string) (*Model, *governor.Error)

NewDown creates a new downvote

func NewDownPost

func NewDownPost(postid, group, userid string) (*Model, *governor.Error)

NewDownPost creates a new downvote for a post

func NewPost

func NewPost(postid, group, userid string, score int16) (*Model, *governor.Error)

NewPost creates a new Vote Model for a post

func NewUp

func NewUp(itemid, postid, group, userid string) (*Model, *governor.Error)

NewUp creates a new upvote

func NewUpPost

func NewUpPost(postid, group, userid string) (*Model, *governor.Error)

NewUpPost creates a new upvote for a post

func (*Model) Delete

func (m *Model) Delete(db *sql.DB) *governor.Error

Delete deletes the model in the db

func (*Model) Down

func (m *Model) Down()

Down makes the vote a downvote

func (*Model) IDBase64

func (m *Model) IDBase64() (string, *governor.Error)

IDBase64 returns the item as a base64 encoded string

func (*Model) Insert

func (m *Model) Insert(db *sql.DB) *governor.Error

Insert inserts the model into the db

func (*Model) IsDown

func (m *Model) IsDown() bool

func (*Model) IsUp

func (m *Model) IsUp() bool

func (*Model) PostIDBase64

func (m *Model) PostIDBase64() (string, *governor.Error)

PostIDBase64 returns the post as a base64 encoded string

func (*Model) Up

func (m *Model) Up()

Up makes the vote an upvote

func (*Model) Update

func (m *Model) Update(db *sql.DB) *governor.Error

Update updates the model in the db

func (*Model) Voteid

func (m *Model) Voteid() []byte

Voteid returns the voteid for a vote

type ModelInfo

type ModelInfo struct {
	Itemid []byte `json:"itemid"`
	Userid string `json:"userid"`
	Score  int16  `json:"score"`
}

ModelInfo is the core vote information

func GetVotesGroupByUser

func GetVotesGroupByUser(db *sql.DB, userid, group string) ([]ModelInfo, *governor.Error)

GetVotesGroupByUser returns the votes of a user for a group

func GetVotesThreadByUser

func GetVotesThreadByUser(db *sql.DB, userid, postid string) ([]ModelInfo, *governor.Error)

GetVotesThreadByUser returns the votes of a user for a thread

func (*ModelInfo) Voteid

func (m *ModelInfo) Voteid() []byte

Voteid returns the voteid for a vote

Jump to

Keyboard shortcuts

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