storage

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrNoBookmarkURL is returned if the Bookmark does not have a URL
	ErrNoBookmarkURL = errors.New("Missing Bookmark.URL")

	// ErrNoBookmarkKey is returned if the Bookmark does not have a ID or URL
	ErrNoBookmarkKey = errors.New("Missing Bookmark.ID or Bookmark.URL")
)
View Source
var (
	// ErrNoFeedURL is returned if the Feed does not have a URL
	ErrNoFeedURL = errors.New("Missing Feed.URL")

	// ErrNoFeedKey is returned if the Feed does not have a ID or URL
	ErrNoFeedKey = errors.New("Missing Feed.ID or Feed.URL")

	// ErrNotExistingFeedItem is returned if a feed does not contain an item
	ErrNotExistingFeedItem = errors.New("Item does not exist in Feed")
)
View Source
var (
	// ErrNoThoughtTitle is returned if the Thought does not have a Title
	ErrNoThoughtTitle = errors.New("Missing Thought.Title")

	// ErrNoThoughtKey is returned if the Thought does not have a ID or Title
	ErrNoThoughtKey = errors.New("Missing Thought.ID or Thought.Title")
)

Functions

This section is empty.

Types

type Bookmark

type Bookmark struct {
	ID       string
	URL      string
	Title    string
	Created  time.Time
	Updated  time.Time
	Excerpt  string
	Content  string `json:",omitempty"`
	Tags     Tags
	Archived bool
}

Bookmark represents a single bookmark

func (*Bookmark) Fetch

func (bookmark *Bookmark) Fetch() error

Fetch downloads the bookmark, reduces the result to a readable plain text format

type Feed

type Feed struct {
	ID           string
	Created      time.Time
	Updated      time.Time
	Refreshed    time.Time
	LastAuthored time.Time
	Title        string
	URL          string
	Etag         string
	Tags         Tags
	Items        FeedItems
}

Feed represents a feed in the database

func (*Feed) DeleteItem

func (feed *Feed) DeleteItem(ID string) error

DeleteItem removes an item by ID from this feed list of items

func (*Feed) Fetch

func (feed *Feed) Fetch() error

Fetch fetches new items from the given Feed

func (*Feed) GetItem

func (feed *Feed) GetItem(ID string) *FeedItem

GetItem gets an item by ID from this feed list of items

type FeedItem

type FeedItem struct {
	ID      string
	Created time.Time
	Updated time.Time
	Title   string
	Date    time.Time
	URL     string
	Content string
}

FeedItem represents a FeedItem as part of a Feed

func (*FeedItem) Scan

func (i *FeedItem) Scan(value interface{}) error

Scan implements the Scanner interface

func (*FeedItem) ToBookmark

func (item *FeedItem) ToBookmark() *Bookmark

ToBookmark converts the feed item to a bookmark

func (FeedItem) Value

func (i FeedItem) Value() (driver.Value, error)

Value implements the Valuer interface

type FeedItems

type FeedItems []*FeedItem

FeedItems represents a slice of FeedItem

func (*FeedItems) Scan

func (i *FeedItems) Scan(value interface{}) error

Scan implements the Scanner interface

func (FeedItems) Value

func (i FeedItems) Value() (driver.Value, error)

Value implements the Valuer interface

type ListBookmarksOptions

type ListBookmarksOptions struct {
	Search      string
	Tags        Tags
	ReadItLater bool
	Limit       int
	Offset      int
}

ListBookmarksOptions can be passed to ListBookmarks to filter bookmarks

type ListFeedsOptions

type ListFeedsOptions struct {
	Search            string
	Tags              Tags
	NotRefreshedSince time.Time
	Limit             int
	Offset            int
}

ListFeedsOptions is used to pass filters to ListFeeds

type ListThoughtsOptions

type ListThoughtsOptions struct {
	Search string
	Tags   Tags
	Limit  int
	Offset int
}

ListThoughtsOptions can be passed to ListThoughts to filter thoughts

type Store

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

Store is used to persist Bookmark, Feed and Thougt

func New

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

New returns a new instance of a Bookmarks Store

func (*Store) Authenticate

func (store *Store) Authenticate(username string, password string) (string, error)

Authenticate authenticates a user with a password and returns the token for the user

func (*Store) DeleteBookmark

func (store *Store) DeleteBookmark(bookmark *Bookmark) error

DeleteBookmark deletes the given bookmark from the database

func (*Store) DeleteFeed

func (store *Store) DeleteFeed(feed *Feed) error

DeleteFeed deletes the given feed from the database

func (*Store) DeleteThought

func (store *Store) DeleteThought(thought *Thought) error

DeleteThought removes a thought from the database

func (*Store) GetBookmark

func (store *Store) GetBookmark(bookmark *Bookmark) error

GetBookmark finds a single bookmark by ID or URL

func (*Store) GetFeed

func (store *Store) GetFeed(feed *Feed) error

GetFeed finds a single feed by ID or URL

func (*Store) GetThought

func (store *Store) GetThought(thought *Thought) error

GetThought gets a single thought from the database

func (*Store) GetUser

func (store *Store) GetUser(user *User) error

GetUser finds a single user by Username

func (*Store) ListBookmarks

func (store *Store) ListBookmarks(options *ListBookmarksOptions) (*[]*Bookmark, int)

ListBookmarks fetches multiple bookmarks from the database

func (*Store) ListFeeds

func (store *Store) ListFeeds(options *ListFeedsOptions) (*[]*Feed, int)

ListFeeds fetches multiple feeds from the database

func (*Store) ListThoughts

func (store *Store) ListThoughts(options *ListThoughtsOptions) (*[]*Thought, int)

ListThoughts lists thoughts from the database

func (*Store) PersistBookmark

func (store *Store) PersistBookmark(bookmark *Bookmark) error

PersistBookmark persists a bookmark to the database and schedules an async job to fetch the content

func (*Store) PersistFeed

func (store *Store) PersistFeed(feed *Feed) error

PersistFeed persists a feed to the database and schedules an async job to fetch the content

func (*Store) PersistThought

func (store *Store) PersistThought(thought *Thought) error

PersistThought adds a thought to the database

func (*Store) RefreshFeed

func (store *Store) RefreshFeed(feed *Feed) error

RefreshFeed fetches the rss feed items and persists those to the database

func (*Store) UserTokenExists

func (store *Store) UserTokenExists(token string) bool

UserTokenExists checks if there is exactly one user with the given token

type Tags

type Tags []string

Tags is a slice of string values

func (*Tags) Scan

func (t *Tags) Scan(value interface{}) error

Scan implements the Scanner interface

func (Tags) Value

func (t Tags) Value() (driver.Value, error)

Value implements the Valuer interface

type Thought

type Thought struct {
	ID      string
	Created time.Time
	Updated time.Time
	Title   string
	Content string `json:",omitempty"`
	Tags    Tags
}

Thought holds information about a thought

type User

type User struct {
	Username string
	Password string
	Token    string
	Created  time.Time
	Updated  time.Time
}

User represents a user that can authenticate to the bookmarks service

Jump to

Keyboard shortcuts

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