Documentation ¶
Overview ¶
Package storage implements a set of functions to interact with the database.
Index ¶
- type EntryQueryBuilder
- func (e *EntryQueryBuilder) Before(date *time.Time) *EntryQueryBuilder
- func (e *EntryQueryBuilder) CountEntries() (count int, err error)
- func (e *EntryQueryBuilder) GetEntries() (model.Entries, error)
- func (e *EntryQueryBuilder) GetEntry() (*model.Entry, error)
- func (e *EntryQueryBuilder) GetEntryIDs() ([]int64, error)
- func (e *EntryQueryBuilder) WithCategoryID(categoryID int64) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithDirection(direction string) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithEntryID(entryID int64) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithEntryIDs(entryIDs []int64) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithFeedID(feedID int64) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithGreaterThanEntryID(entryID int64) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithLimit(limit int) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithOffset(offset int) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithOrder(order string) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithStarred() *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithStatus(status string) *EntryQueryBuilder
- func (e *EntryQueryBuilder) WithoutStatus(status string) *EntryQueryBuilder
- type Storage
- func (s *Storage) AnotherCategoryExists(userID, categoryID int64, title string) bool
- func (s *Storage) AnotherUserExists(userID int64, username string) bool
- func (s *Storage) ArchiveEntries() error
- func (s *Storage) Categories(userID int64) (model.Categories, error)
- func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error)
- func (s *Storage) Category(userID, categoryID int64) (*model.Category, error)
- func (s *Storage) CategoryByTitle(userID int64, title string) (*model.Category, error)
- func (s *Storage) CategoryExists(userID, categoryID int64) bool
- func (s *Storage) CheckPassword(username, password string) error
- func (s *Storage) CleanOldSessions() int64
- func (s *Storage) CleanOldUserSessions() int64
- func (s *Storage) Close()
- func (s *Storage) CountFeeds(userID int64) int
- func (s *Storage) CountUnreadEntries(userID int64) int
- func (s *Storage) CreateCategory(category *model.Category) error
- func (s *Storage) CreateEnclosure(enclosure *model.Enclosure) error
- func (s *Storage) CreateFeed(feed *model.Feed) error
- func (s *Storage) CreateFeedIcon(feed *model.Feed, icon *model.Icon) error
- func (s *Storage) CreateIcon(icon *model.Icon) error
- func (s *Storage) CreateIntegration(userID int64) error
- func (s *Storage) CreateSession() (*model.Session, error)
- func (s *Storage) CreateUser(user *model.User) (err error)
- func (s *Storage) CreateUserSession(username, userAgent, ip string) (sessionID string, userID int64, err error)
- func (s *Storage) EntryURLExists(userID int64, entryURL string) bool
- func (s *Storage) FeedByID(userID, feedID int64) (*model.Feed, error)
- func (s *Storage) FeedExists(userID, feedID int64) bool
- func (s *Storage) FeedURLExists(userID int64, feedURL string) bool
- func (s *Storage) Feeds(userID int64) (model.Feeds, error)
- func (s *Storage) FirstCategory(userID int64) (*model.Category, error)
- func (s *Storage) FlushAllSessions() (err error)
- func (s *Storage) FlushHistory(userID int64) error
- func (s *Storage) GetEnclosures(entryID int64) (model.EnclosureList, error)
- func (s *Storage) HasDuplicateFeverUsername(userID int64, feverUsername string) bool
- func (s *Storage) HasIcon(feedID int64) bool
- func (s *Storage) HasPassword(userID int64) (bool, error)
- func (s *Storage) HasSaveEntry(userID int64) (result bool)
- func (s *Storage) IconByFeedID(userID, feedID int64) (*model.Icon, error)
- func (s *Storage) IconByHash(icon *model.Icon) error
- func (s *Storage) IconByID(iconID int64) (*model.Icon, error)
- func (s *Storage) Icons(userID int64) (model.Icons, error)
- func (s *Storage) Integration(userID int64) (*model.Integration, error)
- func (s *Storage) IsEnclosureExists(enclosure *model.Enclosure) bool
- func (s *Storage) MarkAllAsRead(userID int64) error
- func (s *Storage) Migrate()
- func (s *Storage) NewBatch(batchSize int) (jobs model.JobList, err error)
- func (s *Storage) NewEntryQueryBuilder(userID int64) *EntryQueryBuilder
- func (s *Storage) NewUserBatch(userID int64, batchSize int) (jobs model.JobList, err error)
- func (s *Storage) RemoveCategory(userID, categoryID int64) error
- func (s *Storage) RemoveExtraField(userID int64, field string) error
- func (s *Storage) RemoveFeed(userID, feedID int64) error
- func (s *Storage) RemoveUser(userID int64) error
- func (s *Storage) RemoveUserSessionByID(userID, sessionID int64) error
- func (s *Storage) RemoveUserSessionByToken(userID int64, token string) error
- func (s *Storage) Session(id string) (*model.Session, error)
- func (s *Storage) SetEntriesStatus(userID int64, entryIDs []int64, status string) error
- func (s *Storage) SetLastLogin(userID int64) error
- func (s *Storage) Timezones() (map[string]string, error)
- func (s *Storage) ToggleBookmark(userID int64, entryID int64) error
- func (s *Storage) UpdateCategory(category *model.Category) error
- func (s *Storage) UpdateEnclosures(enclosures model.EnclosureList) error
- func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries, updateExistingEntries bool) (err error)
- func (s *Storage) UpdateEntryContent(entry *model.Entry) error
- func (s *Storage) UpdateExtraField(userID int64, field, value string) error
- func (s *Storage) UpdateFeed(feed *model.Feed) (err error)
- func (s *Storage) UpdateIntegration(integration *model.Integration) error
- func (s *Storage) UpdateSessionField(sessionID, field string, value interface{}) error
- func (s *Storage) UpdateUser(user *model.User) error
- func (s *Storage) UserByExtraField(field, value string) (*model.User, error)
- func (s *Storage) UserByFeverToken(token string) (*model.User, error)
- func (s *Storage) UserByID(userID int64) (*model.User, error)
- func (s *Storage) UserByUsername(username string) (*model.User, error)
- func (s *Storage) UserExists(username string) bool
- func (s *Storage) UserLanguage(userID int64) (language string, err error)
- func (s *Storage) UserSessionByToken(token string) (*model.UserSession, error)
- func (s *Storage) UserSessions(userID int64) (model.UserSessions, error)
- func (s *Storage) Users() (model.Users, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EntryQueryBuilder ¶
type EntryQueryBuilder struct {
// contains filtered or unexported fields
}
EntryQueryBuilder builds a SQL query to fetch entries.
func NewEntryQueryBuilder ¶
func NewEntryQueryBuilder(store *Storage, userID int64) *EntryQueryBuilder
NewEntryQueryBuilder returns a new EntryQueryBuilder.
func (*EntryQueryBuilder) Before ¶
func (e *EntryQueryBuilder) Before(date *time.Time) *EntryQueryBuilder
Before add condition base on the entry date.
func (*EntryQueryBuilder) CountEntries ¶
func (e *EntryQueryBuilder) CountEntries() (count int, err error)
CountEntries count the number of entries that match the condition.
func (*EntryQueryBuilder) GetEntries ¶
func (e *EntryQueryBuilder) GetEntries() (model.Entries, error)
GetEntries returns a list of entries that match the condition.
func (*EntryQueryBuilder) GetEntry ¶
func (e *EntryQueryBuilder) GetEntry() (*model.Entry, error)
GetEntry returns a single entry that match the condition.
func (*EntryQueryBuilder) GetEntryIDs ¶
func (e *EntryQueryBuilder) GetEntryIDs() ([]int64, error)
GetEntryIDs returns a list of entry IDs that match the condition.
func (*EntryQueryBuilder) WithCategoryID ¶
func (e *EntryQueryBuilder) WithCategoryID(categoryID int64) *EntryQueryBuilder
WithCategoryID set the categoryID.
func (*EntryQueryBuilder) WithDirection ¶
func (e *EntryQueryBuilder) WithDirection(direction string) *EntryQueryBuilder
WithDirection set the sorting direction.
func (*EntryQueryBuilder) WithEntryID ¶
func (e *EntryQueryBuilder) WithEntryID(entryID int64) *EntryQueryBuilder
WithEntryID set the entryID.
func (*EntryQueryBuilder) WithEntryIDs ¶
func (e *EntryQueryBuilder) WithEntryIDs(entryIDs []int64) *EntryQueryBuilder
WithEntryIDs adds a condition to fetch only the given entry IDs.
func (*EntryQueryBuilder) WithFeedID ¶
func (e *EntryQueryBuilder) WithFeedID(feedID int64) *EntryQueryBuilder
WithFeedID set the feedID.
func (*EntryQueryBuilder) WithGreaterThanEntryID ¶
func (e *EntryQueryBuilder) WithGreaterThanEntryID(entryID int64) *EntryQueryBuilder
WithGreaterThanEntryID adds a condition > entryID.
func (*EntryQueryBuilder) WithLimit ¶
func (e *EntryQueryBuilder) WithLimit(limit int) *EntryQueryBuilder
WithLimit set the limit.
func (*EntryQueryBuilder) WithOffset ¶
func (e *EntryQueryBuilder) WithOffset(offset int) *EntryQueryBuilder
WithOffset set the offset.
func (*EntryQueryBuilder) WithOrder ¶
func (e *EntryQueryBuilder) WithOrder(order string) *EntryQueryBuilder
WithOrder set the sorting order.
func (*EntryQueryBuilder) WithStarred ¶
func (e *EntryQueryBuilder) WithStarred() *EntryQueryBuilder
WithStarred adds starred filter.
func (*EntryQueryBuilder) WithStatus ¶
func (e *EntryQueryBuilder) WithStatus(status string) *EntryQueryBuilder
WithStatus set the entry status.
func (*EntryQueryBuilder) WithoutStatus ¶
func (e *EntryQueryBuilder) WithoutStatus(status string) *EntryQueryBuilder
WithoutStatus set the entry status that should not be returned.
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage handles all operations related to the database.
func NewStorage ¶
NewStorage returns a new Storage.
func (*Storage) AnotherCategoryExists ¶
AnotherCategoryExists checks if another category exists with the same title.
func (*Storage) AnotherUserExists ¶
AnotherUserExists checks if another user exists with the given username.
func (*Storage) ArchiveEntries ¶
ArchiveEntries changes the status of read items to "removed" after 60 days.
func (*Storage) Categories ¶
func (s *Storage) Categories(userID int64) (model.Categories, error)
Categories returns all categories that belongs to the given user.
func (*Storage) CategoriesWithFeedCount ¶
func (s *Storage) CategoriesWithFeedCount(userID int64) (model.Categories, error)
CategoriesWithFeedCount returns all categories with the number of feeds.
func (*Storage) CategoryByTitle ¶
CategoryByTitle finds a category by the title.
func (*Storage) CategoryExists ¶
CategoryExists checks if the given category exists into the database.
func (*Storage) CheckPassword ¶
CheckPassword validate the hashed password.
func (*Storage) CleanOldSessions ¶
CleanOldSessions removes sessions older than 30 days.
func (*Storage) CleanOldUserSessions ¶
CleanOldUserSessions removes user sessions older than 30 days.
func (*Storage) CountFeeds ¶
CountFeeds returns the number of feeds that belongs to the given user.
func (*Storage) CountUnreadEntries ¶
CountUnreadEntries returns the number of unread entries.
func (*Storage) CreateCategory ¶
CreateCategory creates a new category.
func (*Storage) CreateEnclosure ¶
CreateEnclosure creates a new attachment.
func (*Storage) CreateFeed ¶
CreateFeed creates a new feed.
func (*Storage) CreateFeedIcon ¶
CreateFeedIcon creates an icon and associate the icon to the given feed.
func (*Storage) CreateIcon ¶
CreateIcon creates a new icon.
func (*Storage) CreateIntegration ¶
CreateIntegration creates initial user integration settings.
func (*Storage) CreateSession ¶
CreateSession creates a new session.
func (*Storage) CreateUser ¶
CreateUser creates a new user.
func (*Storage) CreateUserSession ¶
func (s *Storage) CreateUserSession(username, userAgent, ip string) (sessionID string, userID int64, err error)
CreateUserSession creates a new sessions.
func (*Storage) EntryURLExists ¶
EntryURLExists returns true if an entry with this URL already exists.
func (*Storage) FeedExists ¶
FeedExists checks if the given feed exists.
func (*Storage) FeedURLExists ¶
FeedURLExists checks if feed URL already exists.
func (*Storage) FirstCategory ¶
FirstCategory returns the first category for the given user.
func (*Storage) FlushAllSessions ¶
FlushAllSessions removes all sessions from the database.
func (*Storage) FlushHistory ¶
FlushHistory set all entries with the status "read" to "removed".
func (*Storage) GetEnclosures ¶
func (s *Storage) GetEnclosures(entryID int64) (model.EnclosureList, error)
GetEnclosures returns all attachments for the given entry.
func (*Storage) HasDuplicateFeverUsername ¶
HasDuplicateFeverUsername checks if another user have the same fever username.
func (*Storage) HasPassword ¶
HasPassword returns true if the given user has a password defined.
func (*Storage) HasSaveEntry ¶
HasSaveEntry returns true if the given user can save articles to third-parties.
func (*Storage) IconByFeedID ¶
IconByFeedID returns a feed icon.
func (*Storage) IconByHash ¶
IconByHash returns an icon by the hash (checksum).
func (*Storage) Integration ¶
func (s *Storage) Integration(userID int64) (*model.Integration, error)
Integration returns user integration settings.
func (*Storage) IsEnclosureExists ¶
IsEnclosureExists checks if an attachment exists.
func (*Storage) MarkAllAsRead ¶
MarkAllAsRead set all entries with the status "unread" to "read".
func (*Storage) NewEntryQueryBuilder ¶
func (s *Storage) NewEntryQueryBuilder(userID int64) *EntryQueryBuilder
NewEntryQueryBuilder returns a new EntryQueryBuilder
func (*Storage) NewUserBatch ¶
NewUserBatch returns a serie of jobs but only for a given user.
func (*Storage) RemoveCategory ¶
RemoveCategory deletes a category.
func (*Storage) RemoveExtraField ¶
RemoveExtraField deletes an extra field for the given user.
func (*Storage) RemoveFeed ¶
RemoveFeed removes a feed.
func (*Storage) RemoveUser ¶
RemoveUser deletes a user.
func (*Storage) RemoveUserSessionByID ¶
RemoveUserSessionByID remove a session by using the ID.
func (*Storage) RemoveUserSessionByToken ¶
RemoveUserSessionByToken remove a session by using the token.
func (*Storage) SetEntriesStatus ¶
SetEntriesStatus update the status of the given list of entries.
func (*Storage) SetLastLogin ¶
SetLastLogin updates the last login date of a user.
func (*Storage) ToggleBookmark ¶
ToggleBookmark toggles entry bookmark value.
func (*Storage) UpdateCategory ¶
UpdateCategory updates an existing category.
func (*Storage) UpdateEnclosures ¶
func (s *Storage) UpdateEnclosures(enclosures model.EnclosureList) error
UpdateEnclosures add missing attachments while updating a feed.
func (*Storage) UpdateEntries ¶
func (s *Storage) UpdateEntries(userID, feedID int64, entries model.Entries, updateExistingEntries bool) (err error)
UpdateEntries updates a list of entries while refreshing a feed.
func (*Storage) UpdateEntryContent ¶
UpdateEntryContent updates entry content.
func (*Storage) UpdateExtraField ¶
UpdateExtraField updates an extra field of the given user.
func (*Storage) UpdateFeed ¶
UpdateFeed updates an existing feed.
func (*Storage) UpdateIntegration ¶
func (s *Storage) UpdateIntegration(integration *model.Integration) error
UpdateIntegration saves user integration settings.
func (*Storage) UpdateSessionField ¶
UpdateSessionField updates only one session field.
func (*Storage) UpdateUser ¶
UpdateUser updates a user.
func (*Storage) UserByExtraField ¶
UserByExtraField finds a user by an extra field value.
func (*Storage) UserByFeverToken ¶
UserByFeverToken returns a user by using the Fever API token.
func (*Storage) UserByUsername ¶
UserByUsername finds a user by the username.
func (*Storage) UserExists ¶
UserExists checks if a user exists by using the given username.
func (*Storage) UserLanguage ¶
UserLanguage returns the language of the given user.
func (*Storage) UserSessionByToken ¶
func (s *Storage) UserSessionByToken(token string) (*model.UserSession, error)
UserSessionByToken finds a session by the token.
func (*Storage) UserSessions ¶
func (s *Storage) UserSessions(userID int64) (model.UserSessions, error)
UserSessions returns the list of sessions for the given user.