rename store methods
This commit is contained in:
+5
-5
@@ -372,8 +372,8 @@ func (b *BoltDB) GetByUser(locator Locator, userID string) (comments []Comment,
|
||||
return comments, err
|
||||
}
|
||||
|
||||
// GetComment for locator.URL and commentID string
|
||||
func (b *BoltDB) GetComment(locator Locator, commentID string) (comment Comment, err error) {
|
||||
// Get for locator.URL and commentID string
|
||||
func (b *BoltDB) Get(locator Locator, commentID string) (comment Comment, err error) {
|
||||
|
||||
err = b.View(func(tx *bolt.Tx) error {
|
||||
bucket := tx.Bucket([]byte(locator.URL))
|
||||
@@ -395,10 +395,10 @@ func (b *BoltDB) GetComment(locator Locator, commentID string) (comment Comment,
|
||||
return comment, err
|
||||
}
|
||||
|
||||
// PutComment updates comment for locator.URL with mutable part of comment
|
||||
func (b *BoltDB) PutComment(locator Locator, comment Comment) error {
|
||||
// Put updates comment for locator.URL with mutable part of comment
|
||||
func (b *BoltDB) Put(locator Locator, comment Comment) error {
|
||||
|
||||
if curComment, err := b.GetComment(locator, comment.ID); err == nil {
|
||||
if curComment, err := b.Get(locator, comment.ID); err == nil {
|
||||
// preserve immutable fields
|
||||
comment.ParentID = curComment.ParentID
|
||||
comment.Locator = curComment.Locator
|
||||
|
||||
@@ -9,18 +9,18 @@ type Service struct {
|
||||
|
||||
// SetPin pin/un-pin comment as special
|
||||
func (s *Service) SetPin(locator Locator, commentID string, status bool) error {
|
||||
comment, err := s.GetComment(locator, commentID)
|
||||
comment, err := s.Get(locator, commentID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
comment.Pin = status
|
||||
return s.PutComment(locator, comment)
|
||||
return s.Put(locator, comment)
|
||||
}
|
||||
|
||||
// Vote for comment by id and locator
|
||||
func (s *Service) Vote(locator Locator, commentID string, userID string, val bool) (comment Comment, err error) {
|
||||
|
||||
comment, err = s.GetComment(locator, commentID)
|
||||
comment, err = s.Get(locator, commentID)
|
||||
if err != nil {
|
||||
return comment, err
|
||||
}
|
||||
@@ -37,5 +37,5 @@ func (s *Service) Vote(locator Locator, commentID string, userID string, val boo
|
||||
comment.Score--
|
||||
}
|
||||
|
||||
return comment, s.PutComment(locator, comment)
|
||||
return comment, s.Put(locator, comment)
|
||||
}
|
||||
|
||||
+2
-2
@@ -54,8 +54,8 @@ type Request struct {
|
||||
// Interface defines basic CRUD for comments
|
||||
type Interface interface {
|
||||
Create(comment Comment) (commentID string, err error)
|
||||
GetComment(locator Locator, commentID string) (comment Comment, err error)
|
||||
PutComment(locator Locator, comment Comment) error
|
||||
Get(locator Locator, commentID string) (comment Comment, err error)
|
||||
Put(locator Locator, comment Comment) error
|
||||
Delete(locator Locator, commentID string) error
|
||||
Find(request Request) ([]Comment, error)
|
||||
Last(locator Locator, max int) ([]Comment, error)
|
||||
|
||||
Reference in New Issue
Block a user