Add unified post storage (#3)
Adds one post creation path for roots and replies, recursive thread loading, body-only updates, root listings, and root-only voting across PostgreSQL and the in-memory store. Co-authored-by: codegirl-007 <s.raide@gmail.com>
This commit was merged in pull request #3.
This commit is contained in:
@@ -144,6 +144,32 @@ func (p *Postgres) UpsertAnswer(ctx context.Context, a *Answer) error {
|
||||
return a.Upsert(ctx)
|
||||
}
|
||||
|
||||
func (p *Postgres) CreatePost(ctx context.Context, post *Post) error {
|
||||
post.db = p.db
|
||||
return post.Create(ctx)
|
||||
}
|
||||
|
||||
func (p *Postgres) GetPost(ctx context.Context, id string) (*Post, error) {
|
||||
return GetPost(ctx, p.db, id)
|
||||
}
|
||||
|
||||
func (p *Postgres) GetPostThread(ctx context.Context, rootID string) (*Post, error) {
|
||||
return GetPostThread(ctx, p.db, rootID)
|
||||
}
|
||||
|
||||
func (p *Postgres) UpdatePost(ctx context.Context, post *Post) error {
|
||||
post.db = p.db
|
||||
return post.Update(ctx)
|
||||
}
|
||||
|
||||
func (p *Postgres) ListRootPosts(ctx context.Context, postDate, viewerID string) ([]Post, error) {
|
||||
return ListRootPosts(ctx, p.db, postDate, viewerID)
|
||||
}
|
||||
|
||||
func (p *Postgres) VotePost(ctx context.Context, userID, postID string, value int) error {
|
||||
return SetPostVote(ctx, p.db, userID, postID, value)
|
||||
}
|
||||
|
||||
func (p *Postgres) Vote(ctx context.Context, userID, questionID string, value int) error {
|
||||
return Vote(ctx, p.db, userID, questionID, value)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user