Documentation
¶
Index ¶
- Variables
- func IdToCacheKey(idHex string) string
- func IsInvalidIDFormat(err error) bool
- func IsInvalidUserIDFormat(err error) bool
- func IsLikeCreationFailed(err error) bool
- func IsLikeDeletionFailed(err error) bool
- func IsLikeNotFound(err error) bool
- func IsLikeUpdateFailed(err error) bool
- type Core
- func (c *Core) Create(ctx context.Context, newLike Like) (Like, error)
- func (c *Core) DeleteByID(ctx context.Context, likeID string) error
- func (c *Core) QueryAllByPostID(ctx context.Context, postID string) ([]Like, error)
- func (c *Core) QueryAllByUserID(ctx context.Context, userID string) ([]Like, error)
- func (c *Core) QueryByID(ctx context.Context, likeID string) (Like, error)
- func (c *Core) Update(ctx context.Context, updatedLike Like) (Like, error)
- type Like
- type NewLike
- type Storer
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInvalidIDFormat = fmt.Errorf("invalid ID format") ErrLikeCreationFailed = fmt.Errorf("like creation failed") ErrLikeNotFound = fmt.Errorf("like not found") ErrLikeQueryFailed = fmt.Errorf("failed to query Like by ID") ErrLikeUpdateFailed = fmt.Errorf("like update failed") ErrLikeDeletionFailed = fmt.Errorf("like deletion failed") ErrInvalidUserIDFormat = fmt.Errorf("invalid User ID format") ErrLikeAlreadyExists = fmt.Errorf("like already exist") )
Custom errors for Like operations
Functions ¶
func IdToCacheKey ¶
func IsInvalidIDFormat ¶ added in v0.4.1
IsInvalidIDFormat checks if an error is due to invalid ID format.
func IsInvalidUserIDFormat ¶ added in v0.4.1
IsInvalidUserIDFormat checks if an error is due to invalid User ID format.
func IsLikeCreationFailed ¶ added in v0.4.1
IsLikeCreationFailed checks if an error is due to like creation failure.
func IsLikeDeletionFailed ¶ added in v0.4.1
IsLikeDeletionFailed checks if an error is due to like deletion failure.
func IsLikeNotFound ¶ added in v0.4.1
IsLikeNotFound checks if an error is due to a like not being found.
func IsLikeUpdateFailed ¶ added in v0.4.1
IsLikeUpdateFailed checks if an error is due to like update failure.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
func NewCore ¶
func NewCore(cache cachestore.CacheStore, storer Storer, userStore user.Storer, likeProducer producer.Producer) *Core
func (*Core) QueryAllByPostID ¶
QueryAllByPostID retrieves all likes for a specific post
func (*Core) QueryAllByUserID ¶
type Like ¶
type Like struct {
ID primitive.ObjectID `json:"id,omitempty" bson:"_id,omitempty"`
UserID primitive.ObjectID `json:"user_id,omitempty" bson:"user_id,omitempty"`
PostID int64 `json:"post_id" bson:"post_id,omitempty"`
IsPositive bool `json:"is_positive"`
}
func (Like) CacheExpiration ¶
type Storer ¶
type Storer interface {
Create(ctx context.Context, newLike Like) (Like, error)
QueryByID(ctx context.Context, likeID string) (Like, error)
QueryAllByUserID(ctx context.Context, userID string) ([]Like, error)
QueryAllByPostID(ctx context.Context, postID string) ([]Like, error)
QueryByUserAndPostID(ctx context.Context, userID string, postID int64) (Like, error)
Update(ctx context.Context, updatedLike Like) (Like, error)
DeleteByID(ctx context.Context, likeID string) error
}
Click to show internal directories.
Click to hide internal directories.