db

package
v0.0.0-...-2781dfa Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: MPL-2.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDB

func InitDB(debugFlag bool) (*gorm.DB, error)

Types

type AuthorStatistic

type AuthorStatistic struct {
	gorm.Model
	Author        string
	TotalPosts    int
	TotalUpvotes  int
	TotalComments int
}

AuthorStatistic represents the schema for the "author_statistics" table

type DbStore

type DbStore struct {
	DB *gorm.DB
}

func (*DbStore) ClearAuthorStatistics

func (s *DbStore) ClearAuthorStatistics() error

func (*DbStore) ClearPosts

func (s *DbStore) ClearPosts() error

func (*DbStore) GetToken

func (s *DbStore) GetToken() (*oauth2.Token, error)

func (*DbStore) GetTopPoster

func (s *DbStore) GetTopPoster() ([]socialmedia.AuthorStatistic, error)

func (*DbStore) GetTopPosts

func (s *DbStore) GetTopPosts() ([]socialmedia.Post, error)

func (*DbStore) SaveAuthorStatistic

func (s *DbStore) SaveAuthorStatistic(p *socialmedia.Post) error

func (*DbStore) SavePost

func (s *DbStore) SavePost(p *socialmedia.Post) error

func (*DbStore) SaveToken

func (s *DbStore) SaveToken(token *oauth2.Token) error

func (*DbStore) TransformToDBPost

func (s *DbStore) TransformToDBPost(p *socialmedia.Post) *Post

type Post

type Post struct {
	gorm.Model
	PostID      string `gorm:"unique"`
	Author      string
	Subreddit   string
	Title       string
	UpVotes     int
	NumComments int
}

Post represents the schema for the "posts" table

type Token

type Token struct {
	gorm.Model
	OAuthData string
	ExpiresAt time.Time
}

Jump to

Keyboard shortcuts

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