postmodel

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: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseB64ToUID

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

ParseB64ToUID converts a postid in base64 into a UID

func ParseUIDToB64

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

ParseUIDToB64 converts a UID postid into base64

func Setup

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

Setup creates a new Post table

Types

type Model

type Model struct {
	ModelInfo
	Content string `json:"content"`
	Locked  bool   `json:"locked"`
}

Model is the db Post model

func GetByIDB64

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

GetByIDB64 returns a post model with the given base64 id

func New

func New(userid, tag, title, content string) (*Model, *governor.Error)

New creates a new Post Model

func (*Model) Delete

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

Delete deletes the model in the db

func (*Model) IDBase64

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

IDBase64 returns the postid 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) IsLocked

func (m *Model) IsLocked() bool

IsLocked returns if the post is locked

func (*Model) Lock

func (m *Model) Lock()

Lock locks the post

func (*Model) Rescore

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

Rescore updates the score

func (*Model) Unlock

func (m *Model) Unlock()

Unlock unlocks the post

func (*Model) Update

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

Update updates the model in the db

type ModelInfo

type ModelInfo struct {
	Postid       []byte `json:"postid"`
	Userid       string `json:"userid"`
	Tag          string `json:"group_tag"`
	Title        string `json:"title"`
	Up           int32  `json:"up"`
	Down         int32  `json:"down"`
	Absolute     int32  `json:"absolute"`
	Score        int64  `json:"score"`
	CreationTime int64  `json:"creation_time"`
}

ModelInfo is metadata of a post

type ModelSlice

type ModelSlice []ModelInfo

ModelSlice is an array of posts

func GetGroup

func GetGroup(db *sql.DB, tag string, limit, offset int) (ModelSlice, *governor.Error)

GetGroup returns a list of posts from a group

Jump to

Keyboard shortcuts

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