-
Notifications
You must be signed in to change notification settings - Fork 0
/
goreddit.go
68 lines (62 loc) · 1.65 KB
/
goreddit.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package goreddit
import "github.com/google/uuid"
type User struct {
ID uuid.UUID `db:"id"`
Username string `db:"username"`
Password string `db:"password"`
}
type Thread struct {
ID uuid.UUID `db:"id"`
Title string `db:"title"`
Description string `db:"description"`
}
type Post struct {
ID uuid.UUID `db:"id"`
ThreadID uuid.UUID `db:"thread_id"`
Title string `db:"title"`
Content string `db:"content"`
Votes int `db:"votes"`
CommentsCount int `db:"comments_count"`
ThreadTitle string `db:"thread_title"`
}
type Comment struct {
ID uuid.UUID `db:"id"`
PostID uuid.UUID `db:"post_id"`
Content string `db:"content"`
Votes int `db:"votes"`
}
type ThreadStore interface {
Thread(id uuid.UUID) (Thread, error)
Threads() ([]Thread, error)
CreateThread(t *Thread) error
UpdateThread(t *Thread) error
DeleteThread(id uuid.UUID) error
}
type PostStore interface {
Post(id uuid.UUID) (Post, error)
Posts() ([]Post, error)
PostsByThread(threadID uuid.UUID) ([]Post, error)
CreatePost(t *Post) error
UpdatePost(t *Post) error
DeletePost(id uuid.UUID) error
}
type CommentStore interface {
Comment(id uuid.UUID) (Comment, error)
CommentsByPost(postID uuid.UUID) ([]Comment, error)
CreateComment(t *Comment) error
UpdateComment(t *Comment) error
DeleteComment(id uuid.UUID) error
}
type UserStore interface {
User(id uuid.UUID) (User, error)
UserByUsername(username string) (User, error)
CreateUser(t *User) error
UpdateUser(t *User) error
DeleteUser(id uuid.UUID) error
}
type Store interface {
ThreadStore
PostStore
CommentStore
UserStore
}