-
-
Notifications
You must be signed in to change notification settings - Fork 262
/
storage.go
44 lines (31 loc) · 1.25 KB
/
storage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package db
import (
"context"
"github.com/mxpv/podsync/pkg/model"
)
type Version int
const (
CurrentVersion = 1
)
type Storage interface {
Close() error
Version() (int, error)
// AddFeed will:
// - Insert or update feed info
// - Append new episodes to the existing list of episodes (existing episodes are not overwritten!)
AddFeed(ctx context.Context, feedID string, feed *model.Feed) error
// GetFeed gets a feed by ID
GetFeed(ctx context.Context, feedID string) (*model.Feed, error)
// WalkFeeds iterates over feeds saved to database
WalkFeeds(ctx context.Context, cb func(feed *model.Feed) error) error
// DeleteFeed deletes feed and all related data from database
DeleteFeed(ctx context.Context, feedID string) error
// GetEpisode gets episode by identifier
GetEpisode(ctx context.Context, feedID string, episodeID string) (*model.Episode, error)
// UpdateEpisode updates episode fields
UpdateEpisode(feedID string, episodeID string, cb func(episode *model.Episode) error) error
// DeleteEpisode deletes an episode
DeleteEpisode(feedID string, episodeID string) error
// WalkEpisodes iterates over episodes that belong to the given feed ID
WalkEpisodes(ctx context.Context, feedID string, cb func(episode *model.Episode) error) error
}