From 3be7821b042346dc5805348e261353bfe92bee9a Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 27 Dec 2017 03:20:46 -0600 Subject: [PATCH] rename store methods --- app/store/bolt.go | 10 +++++----- app/store/service.go | 8 ++++---- app/store/store.go | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/store/bolt.go b/app/store/bolt.go index aef6212e..aafbc1dc 100644 --- a/app/store/bolt.go +++ b/app/store/bolt.go @@ -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 diff --git a/app/store/service.go b/app/store/service.go index 7e5f2e14..e3d361a0 100644 --- a/app/store/service.go +++ b/app/store/service.go @@ -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) } diff --git a/app/store/store.go b/app/store/store.go index ff129284..e4f88764 100644 --- a/app/store/store.go +++ b/app/store/store.go @@ -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)