aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-01-04 18:11:15 -0800
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-01-04 18:11:15 -0800
commitc57cafbef28a8a12cae02674b3c36979acb0e576 (patch)
treedde0c13961831f718867330768742d36fb5f6d60 /storage
parentefac11e0829ded936b08f1e3e072d4f3792fd7da (diff)
Add link to mark everything as read
Diffstat (limited to 'storage')
-rw-r--r--storage/entry.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/storage/entry.go b/storage/entry.go
index 3be6c92..c6058d0 100644
--- a/storage/entry.go
+++ b/storage/entry.go
@@ -213,3 +213,16 @@ func (s *Storage) FlushHistory(userID int64) error {
return nil
}
+
+// MarkAllAsRead set all entries with the status "unread" to "read".
+func (s *Storage) MarkAllAsRead(userID int64) error {
+ defer timer.ExecutionTime(time.Now(), fmt.Sprintf("[Storage:MarkAllAsRead] userID=%d", userID))
+
+ query := `UPDATE entries SET status=$1 WHERE user_id=$2 AND status=$3`
+ _, err := s.db.Exec(query, model.EntryStatusRead, userID, model.EntryStatusUnread)
+ if err != nil {
+ return fmt.Errorf("unable to mark all entries as read: %v", err)
+ }
+
+ return nil
+}