store

package
v0.0.0-...-3c2ccb0 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UserErrUsername = errors.New("invalid username")

Functions

This section is empty.

Types

type PostFrontpage

type PostFrontpage struct {
	Id            int
	Score         int
	Comments      int
	UserUpvoted   bool
	UserDownvoted bool
	Author        string
	Title         string
	URL           string
	Body          string
	Date          *time.Time
}

type PostGet

type PostGet struct {
	Id            int
	Score         int
	UserUpvoted   bool
	UserDownvoted bool
	Author        string
	Title         string
	URL           string
	Body          string
	Date          *time.Time
}

type Store

type Store struct {
	// contains filtered or unexported fields
}

func New

func New(sqliteDataSource string) (*Store, error)

func (*Store) Close

func (s *Store) Close()

func (*Store) PostCreateDownvote

func (s *Store) PostCreateDownvote(userId, postId int) (downvotes int, err error)

func (*Store) PostCreateUpvote

func (s *Store) PostCreateUpvote(userId, postId int) (upvotes int, err error)

func (*Store) PostGet

func (s *Store) PostGet(userId, postId int) *PostGet

func (*Store) PostGetDownvotes

func (s *Store) PostGetDownvotes(postId int) (int, error)

func (*Store) PostGetScore

func (s *Store) PostGetScore(postId int) (int, error)

func (*Store) PostGetUpvotes

func (s *Store) PostGetUpvotes(postId int) (int, error)

func (*Store) PostListFrontpage

func (s *Store) PostListFrontpage(userId, limit, offset int) func(func(*PostFrontpage, error) bool)

func (*Store) PostNew

func (s *Store) PostNew(post *UserPostNew) (id int, err error)

func (*Store) UserDeleteSessionToken

func (s *Store) UserDeleteSessionToken(sessionToken string) error

func (*Store) UserFromSessionToken

func (s *Store) UserFromSessionToken(sessionToken string) (*User, error)

func (*Store) UserFromUsername

func (s *Store) UserFromUsername(username string) (*User, error)

func (*Store) UserNew

func (s *Store) UserNew(username string, hashedPassword []byte) (*User, error)

func (*Store) UserUpdatePassword

func (s *Store) UserUpdatePassword(user *User, currentPassword, newPassword []byte) error

func (*Store) UserUpdateSessionToken

func (s *Store) UserUpdateSessionToken(username string, password []byte) (sessionToken string, err error)

type User

type User struct {
	Id             int
	Username       string
	HashedPassword []byte
	CreatedAt      *time.Time
	SessionToken   sql.NullString
}

type UserPostNew

type UserPostNew struct {
	UserId int
	Title  string
	URL    string
	Body   string
}

Jump to

Keyboard shortcuts

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