storage

package
v0.0.0-...-3c2e532 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoCollection

func NewMongoCollection(collection *mongo.Collection) *mongoCollection

Types

type AbstractCollection

type AbstractCollection interface {
	Find(ctx context.Context, filter any, opts ...*options.FindOptions) (AbstractCursor, error)
	FindOne(ctx context.Context, filter any, opts ...*options.FindOneOptions) AbstractSingleResult
	InsertOne(ctx context.Context, document any, opts ...*options.InsertOneOptions) (any, error)
	UpdateOne(ctx context.Context, filter any, update any, opts ...*options.UpdateOptions) (int64, error)
	DeleteOne(ctx context.Context, filter any, opts ...*options.DeleteOptions) (int64, error)
}

type AbstractCursor

type AbstractCursor interface {
	All(ctx context.Context, result any) error
}

type AbstractSingleResult

type AbstractSingleResult interface {
	Decode(v any) error
	Err() error
}

type PostRepoMongoDB

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

func NewPostRepoMongoDB

func NewPostRepoMongoDB(collection AbstractCollection) *PostRepoMongoDB

func (*PostRepoMongoDB) AddComment

func (p *PostRepoMongoDB) AddComment(ctx context.Context, post *posts.Post, comment posts.Comment) (*posts.Post, error)

func (*PostRepoMongoDB) CreatePost

func (p *PostRepoMongoDB) CreatePost(ctx context.Context, postPayload posts.PostPayload) (*posts.Post, error)

func (*PostRepoMongoDB) DeleteComment

func (p *PostRepoMongoDB) DeleteComment(ctx context.Context, post *posts.Post, commentID users.ID) (*posts.Post, error)

func (*PostRepoMongoDB) DeletePost

func (p *PostRepoMongoDB) DeletePost(ctx context.Context, postID users.ID) error

func (*PostRepoMongoDB) Downvote

func (p *PostRepoMongoDB) Downvote(ctx context.Context, post *posts.Post) (*posts.Post, error)

func (*PostRepoMongoDB) GetAllPosts

func (p *PostRepoMongoDB) GetAllPosts(ctx context.Context) ([]*posts.Post, error)

func (*PostRepoMongoDB) GetPostByID

func (p *PostRepoMongoDB) GetPostByID(ctx context.Context, postID users.ID) (*posts.Post, error)

func (*PostRepoMongoDB) GetPostsByCategory

func (p *PostRepoMongoDB) GetPostsByCategory(ctx context.Context, postCategory posts.PostCategory) ([]*posts.Post, error)

func (*PostRepoMongoDB) GetPostsByUser

func (p *PostRepoMongoDB) GetPostsByUser(ctx context.Context, userLogin users.Username) ([]*posts.Post, error)

func (*PostRepoMongoDB) Unvote

func (p *PostRepoMongoDB) Unvote(ctx context.Context, post *posts.Post) (*posts.Post, error)

func (*PostRepoMongoDB) UpdateViews

func (p *PostRepoMongoDB) UpdateViews(ctx context.Context, postID users.ID) error

func (*PostRepoMongoDB) Upvote

func (p *PostRepoMongoDB) Upvote(ctx context.Context, post *posts.Post) (*posts.Post, error)

type SessionRepoRedis

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

func NewSessionRepoRedis

func NewSessionRepoRedis(client *redis.Client) *SessionRepoRedis

func (*SessionRepoRedis) CheckSession

func (s *SessionRepoRedis) CheckSession(ctx context.Context, sess *jwt.Session) (*jwt.TokenPayload, error)

func (*SessionRepoRedis) CreateSession

func (s *SessionRepoRedis) CreateSession(ctx context.Context, session *jwt.Session, payload *jwt.TokenPayload) (*jwt.Session, error)

type UserRepoMySQL

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

func NewUserRepoMySQL

func NewUserRepoMySQL(db *sql.DB) *UserRepoMySQL

func (*UserRepoMySQL) Authorize

func (repo *UserRepoMySQL) Authorize(ctx context.Context, authData users.AuthUserInfo) (*users.User, error)

func (*UserRepoMySQL) RegisterUser

func (repo *UserRepoMySQL) RegisterUser(ctx context.Context, authData users.AuthUserInfo) (*users.User, error)

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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