Documentation ¶
Overview ¶
Package db contains comment related CRUD functionality.
Index ¶
- type Comment
- type Post
- type PostComment
- type Store
- func (s Store) Create(ctx context.Context, c Comment) error
- func (s Store) CreatePost(ctx context.Context, p Post) error
- func (s Store) Delete(ctx context.Context, commentID string) error
- func (s Store) DeletePost(ctx context.Context, postID string) error
- func (s Store) Query(ctx context.Context, pageNumber int, rowsPerPage int) ([]Comment, error)
- func (s Store) QueryByID(ctx context.Context, commentID string) (Comment, error)
- func (s Store) QueryByPostID(ctx context.Context, postID string) ([]Comment, error)
- func (s Store) QueryByUserID(ctx context.Context, userID string) ([]Comment, error)
- func (s Store) QueryPostsByPostID(ctx context.Context, postID string) ([]PostComment, error)
- func (s Store) Tran(tx sqlx.ExtContext) Store
- func (s Store) Update(ctx context.Context, c Comment) error
- func (s Store) UpdatePost(ctx context.Context, p Post) error
- func (s Store) WithinTran(ctx context.Context, fn func(sqlx.ExtContext) error) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Comment ¶
type Comment struct { ID string `db:"comment_id"` Description string `db:"description"` UserID string `db:"user_id"` PostID string `db:"post_id"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` }
Comment represent the structure we need for moving data between the app and the database.
type PostComment ¶
type PostComment struct { ID string `db:"post_id"` Title string `db:"title"` Description string `db:"description"` UserID string `db:"user_id"` DateCreated time.Time `db:"date_created"` DateUpdated time.Time `db:"date_updated"` CommentID string `db:"comment_id"` CommentDescription string `db:"comment_description"` CommentUserID string `db:"comment_user_id"` CommentDateCreated time.Time `db:"comment_date_created"` CommentDateUpdated time.Time `db:"comment_date_updated"` }
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store manages the set of API's for comment access.
func NewStore ¶
func NewStore(log *zap.SugaredLogger, db *sqlx.DB) Store
NewStore constructs a data for api access.
func (Store) QueryByPostID ¶
func (Store) QueryByUserID ¶
func (Store) QueryPostsByPostID ¶
func (Store) Tran ¶
func (s Store) Tran(tx sqlx.ExtContext) Store
Tran return new Store with transaction in it.
func (Store) WithinTran ¶
WithinTran runs passed function and do commit/rollback at the end.
Click to show internal directories.
Click to hide internal directories.