storage

package
v0.0.0-...-56114fe Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: MIT Imports: 14 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartGC

func StartGC(ctx context.Context, d *Database)

StartGC starts continuously garbage-collecting old read articles on a regular interval.

Types

type Database

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

Database is a wrapper type around a database connection.

func Open

func Open(dbPath string) (*Database, error)

Open opens a connection to the given database path and tests connectivity.

func (*Database) Close

func (d *Database) Close() error

Close closes the database connection.

func (*Database) DeleteArticlesByIdForUser

func (d *Database) DeleteArticlesByIdForUser(u models.User, ids []int64) error

DeleteArticlesByIdForUser deletes articles in the given list of IDs for the given user.

func (*Database) DeleteArticlesForUser

func (d *Database) DeleteArticlesForUser(u models.User, minTimestamp time.Time) (int64, error)

DeleteArticlesForUser deletes all articles earlier than the given timestamp and returns the number deleted.

func (*Database) DeleteFeedForUser

func (d *Database) DeleteFeedForUser(u models.User, feedId int64, folderId int64) error

DeleteFeedForUser deletes the specified feed and all articles under that feed.

func (*Database) GetAllFaviconsForUser

func (d *Database) GetAllFaviconsForUser(u models.User) (map[int64]string, error)

GetAllFaviconsForUser returns a map of feed ID to a base64 representation of its favicon. Feeds with no favicons are not part of the returned map.

func (*Database) GetAllFeedsForUser

func (d *Database) GetAllFeedsForUser(u models.User) ([]models.Feed, error)

GetAllFeedsForUser returns a list of all feeds in the database for the given user.

func (*Database) GetAllFoldersForUser

func (d *Database) GetAllFoldersForUser(u models.User) ([]models.Folder, error)

GetAllFoldersForUser returns a list of all folders in the database for the given user.

func (*Database) GetAllRetrievalCaches

func (d *Database) GetAllRetrievalCaches() (map[string]string, error)

GetAllRetrievalCaches retrieves the cache for all users.

func (*Database) GetAllUsers

func (d *Database) GetAllUsers() ([]models.User, error)

GetAllUsers returns a list of all models.User objects.

func (*Database) GetArticlesForFeedForUser

func (d *Database) GetArticlesForFeedForUser(u models.User, feedId int64) ([]models.Article, error)

GetArticlesForFeedForUser returns a list of articles for the given feed ID and user.

func (*Database) GetArticlesForUser

func (d *Database) GetArticlesForUser(u models.User, ids []int64) ([]models.Article, error)

GetArticlesForUser returns articles from the specified list.

func (*Database) GetFeedsInFolderForUser

func (d *Database) GetFeedsInFolderForUser(u models.User, folderId int64) ([]models.Feed, error)

GetFeedsInFolderForUser returns a list of feeds directly under the given folder for the given user.

func (*Database) GetFeedsPerFolderForUser

func (d *Database) GetFeedsPerFolderForUser(u models.User) (map[int64][]int64, error)

GetFeedsPerFolderForUser returns a map of folder ID to an array of feed IDs.

func (*Database) GetFolderChildrenForUser

func (d *Database) GetFolderChildrenForUser(u models.User, id int64) ([]int64, error)

GetFolderChildrenForUser returns a list of IDs corresponding to folders under the given folder ID.

func (*Database) GetFolderFeedTreeForUser

func (d *Database) GetFolderFeedTreeForUser(u models.User) (*models.Folder, error)

GetFolderFeedTreeForUser returns a root Folder object with associated feeds and recursively populated sub-folders.

func (*Database) GetUnreadArticleMetaForUser

func (d *Database) GetUnreadArticleMetaForUser(u models.User, limit int, sinceID int64) ([]models.Article, error)

GetUnreadArticleMetaForUser returns a list of at most the given limit of articles after the given ID. Only metadata fields are returned, not content.

func (*Database) GetUnreadArticlesForUser

func (d *Database) GetUnreadArticlesForUser(u models.User, limit int, sinceID int64) ([]models.Article, error)

GetUnreadArticlesForUser returns a list of at most the given limit of articles after the given ID.

func (*Database) GetUserByKey

func (d *Database) GetUserByKey(key string) (models.User, error)

GetUserByKey returns a user identified by the given key.

func (*Database) GetUserByUsername

func (d *Database) GetUserByUsername(username string) (models.User, error)

GetUserByUsername returns a user identified by the given username.

func (*Database) ImportOpmlForUser

func (d *Database) ImportOpmlForUser(u models.User, opml *opml.Opml) error

ImportOpmlForUser inserts folders from the given OPML object into the database for the given user.

func (*Database) InsertArticleForUser

func (d *Database) InsertArticleForUser(u models.User, a models.Article) error

InsertArticleForUser inserts the given article object into the database.

func (*Database) InsertFaviconForUser

func (d *Database) InsertFaviconForUser(u models.User, folderId int64, feedId int64, mime string, img []byte) error

InsertFaviconForUser inserts the given favicon and associated metadata into the database.

func (*Database) InsertFeedForUser

func (d *Database) InsertFeedForUser(u models.User, f models.Feed, folderId int64) (int64, error)

InsertFeedForUser inserts a new feed into the database. If `folderId` is 0, the feed is assumed to be a top-level entry. Otherwise, the feed will be nested under the folder with that ID.

func (*Database) InsertFolderForUser

func (d *Database) InsertFolderForUser(u models.User, f models.Folder, parentId int64) (int64, error)

InsertFolderForUser inserts a new folder into the database. If `parentId` is 0, the folder is assumed to be the root folder. Otherwise, the folder will be nested under the folder with that ID.

func (*Database) InsertUser

func (d *Database) InsertUser(u models.User) error

InsertUser inserts the given user into the database.

func (*Database) MarkArticleForUser

func (d *Database) MarkArticleForUser(u models.User, articleId int64, status string) error

MarkArticleForUser sets the read status of the given article to the given status.

func (*Database) MarkFeedForUser

func (d *Database) MarkFeedForUser(u models.User, feedId int64, status string) error

MarkFeedForUser sets the read status of all articles in the given feed to the given status.

func (*Database) MarkFolderForUser

func (d *Database) MarkFolderForUser(u models.User, folderId int64, status string) error

MarkFolderForUser sets the read status of all articles in the given folder to the given status. An ID of 0 will mark all articles in all folders to the given status.

func (*Database) PersistAllRetrievalCaches

func (d *Database) PersistAllRetrievalCaches(entries map[string][]byte) error

PersistAllRetrievalCaches writes the retrieval caches for all users.

func (*Database) UpdateFeedMetadataForUser

func (d *Database) UpdateFeedMetadataForUser(u models.User, f models.Feed) error

UpdateFeedMetadataForUser updates various fields for the row corresponding to given models.Feed object with the values in that object.

func (*Database) UpdateFolderForFeedForUser

func (d *Database) UpdateFolderForFeedForUser(u models.User, feedId int64, folderId int64) error

UpdateFolderForFeedForUser updates the folder of the given feed. The new `folderId` must already exist and is enforced by a foreign key constraint on the `Feed` folder.

func (*Database) UpdateLatestTimeForFeedForUser

func (d *Database) UpdateLatestTimeForFeedForUser(u models.User, folderId int64, id int64, latest time.Time) error

UpdateLatestTimeForFeedForUser sets the latest retrieval time for the given feed to the given timestamp.

Jump to

Keyboard shortcuts

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