models

package
v0.0.0-...-0ca8dff Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DB

type DB struct {
	*sqlx.DB
}

func InitDB

func InitDB(dataSourceName string) (*DB, error)

func (*DB) GetDayHighlights

func (db *DB) GetDayHighlights(timestamp time.Time) ([]Highlight, error)

func (*DB) GetHighlight

func (db *DB) GetHighlight(highlightID string) (Highlight, error)

func (*DB) GetHighlightMirrors

func (db *DB) GetHighlightMirrors(highlightID string) ([]HighlightMirror, error)

func (*DB) GetHighlightsAfterTimestamp

func (db *DB) GetHighlightsAfterTimestamp(timestamp time.Time) ([]Highlight, error)

func (*DB) SaveHighlightMirrors

func (db *DB) SaveHighlightMirrors(highlightMirrors []HighlightMirror) ([]string, error)

func (*DB) SaveHighlights

func (db *DB) SaveHighlights(highlights []Highlight) ([]string, error)

type Datastore

type Datastore interface {
	GetDayHighlights(timestamp time.Time) ([]Highlight, error)
	GetHighlightMirrors(highlightID string) ([]HighlightMirror, error)
	GetHighlightsAfterTimestamp(timestamp time.Time) ([]Highlight, error)
	GetHighlight(highlightID string) (Highlight, error)
	SaveHighlights(highlights []Highlight) ([]string, error)
	SaveHighlightMirrors(highlightMirrors []HighlightMirror) ([]string, error)
}

type Highlight

type Highlight struct {
	ID                 string    `json:"id" db:"id"`
	URL                string    `json:"url" db:"url"`
	Title              string    `json:"title" db:"title"`
	CreatedAt          time.Time `json:"createdAt" db:"created_at"`
	RedditSubmissionID string    `json:"redditSubmissionId" db:"reddit_submission_id"`
	RedditPermalink    string    `json:"redditPermalink" db:"reddit_permalink"`
	RedditAuthor       string    `json:"redditAuthor" db:"reddit_author"`
	RedditCreatedAt    time.Time `json:"redditCreatedAt" db:"reddit_created_at"`
	NumMirrors         int64     `json:"numMirrors" db:"num_mirrors"`
}

type HighlightMirror

type HighlightMirror struct {
	ID              string    `json:"id" db:"id"`
	HighlightID     string    `json:"highlightId" db:"highlight_id"`
	URL             string    `json:"url" db:"url"`
	CreatedAt       time.Time `json:"createdAt" db:"created_at"`
	RedditPermalink string    `json:"redditPermalink" db:"reddit_permalink"`
	RedditAuthor    string    `json:"redditAuthor" db:"reddit_author"`
	RedditCreatedAt time.Time `json:"redditCreatedAt" db:"reddit_created_at"`
}

Jump to

Keyboard shortcuts

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