like

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IdToCacheKey

func IdToCacheKey(idHex string) string

Types

type Core

type Core struct {
	// contains filtered or unexported fields
}

func NewCore

func NewCore(cache cachestore.CacheStore, storer Storer, userStore user.Storer) *Core

func (*Core) Create

func (c *Core) Create(ctx context.Context, newLike Like) (Like, error)

func (*Core) DeleteByID

func (c *Core) DeleteByID(ctx context.Context, likeID string) error

func (*Core) QueryAllByPostID

func (c *Core) QueryAllByPostID(ctx context.Context, postID string) ([]Like, error)

QueryAllByPostID retrieves all likes for a specific post

func (*Core) QueryAllByUserID

func (c *Core) QueryAllByUserID(ctx context.Context, userID string) ([]Like, error)

func (*Core) QueryByID

func (c *Core) QueryByID(ctx context.Context, likeID string) (Like, error)

func (*Core) Update

func (c *Core) Update(ctx context.Context, updatedLike Like) (Like, error)

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

func (p Like) CacheExpiration() time.Duration

func (Like) CacheKey

func (l Like) CacheKey() string

type NewLike

type NewLike struct {
	PostID     int64 `json:"post_id"`
	IsPositive bool  `json:"is_positive"`
}

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, userID string) ([]Like, error)
	Update(ctx context.Context, updatedLike Like) (Like, error)
	DeleteByID(ctx context.Context, likeID string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL