aboutsummaryrefslogtreecommitdiffhomepage
path: root/storage/entry.go
diff options
context:
space:
mode:
Diffstat (limited to 'storage/entry.go')
-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
+}