store

package
v0.0.0-...-b7604bf Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArticleStore

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

ArticleStore is data access struct for user

func NewArticleStore

func NewArticleStore(db *gorm.DB) *ArticleStore

NewArticleStore returns a new ArticleStore

func (*ArticleStore) AddFavorite

func (s *ArticleStore) AddFavorite(a *model.Article, u *model.User) error

AddFavorite favorite an article

func (*ArticleStore) Create

func (s *ArticleStore) Create(m *model.Article) error

Create creates an article

func (*ArticleStore) CreateComment

func (s *ArticleStore) CreateComment(m *model.Comment) error

CreateComment creates a comment of the article

func (*ArticleStore) Delete

func (s *ArticleStore) Delete(m *model.Article) error

Delete deletes an article

func (*ArticleStore) DeleteComment

func (s *ArticleStore) DeleteComment(m *model.Comment) error

DeleteComment deletes an comment

func (*ArticleStore) DeleteFavorite

func (s *ArticleStore) DeleteFavorite(a *model.Article, u *model.User) error

DeleteFavorite unfavorite an article

func (*ArticleStore) GetArticles

func (s *ArticleStore) GetArticles(tagName, username string, favoritedBy *model.User, limit, offset int64) ([]model.Article, error)

GetArticles get global articles

func (*ArticleStore) GetByID

func (s *ArticleStore) GetByID(id uint) (*model.Article, error)

GetByID finds an article from id

func (*ArticleStore) GetCommentByID

func (s *ArticleStore) GetCommentByID(id uint) (*model.Comment, error)

GetCommentByID finds an comment from id

func (*ArticleStore) GetComments

func (s *ArticleStore) GetComments(m *model.Article) ([]model.Comment, error)

GetComments gets coments of the article

func (*ArticleStore) GetFeedArticles

func (s *ArticleStore) GetFeedArticles(userIDs []uint, limit, offset int64) ([]model.Article, error)

GetFeedArticles returns following users' articles

func (*ArticleStore) GetTags

func (s *ArticleStore) GetTags() ([]model.Tag, error)

GetTags creates a article tag

func (*ArticleStore) IsFavorited

func (s *ArticleStore) IsFavorited(a *model.Article, u *model.User) (bool, error)

IsFavorited returns whether the article is favorited by the user

func (*ArticleStore) Update

func (s *ArticleStore) Update(m *model.Article) error

Update updates an article

type UserStore

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

UserStore is data access struct for user

func NewUserStore

func NewUserStore(db *gorm.DB) *UserStore

NewUserStore returns a new UserStore

func (*UserStore) Create

func (s *UserStore) Create(m *model.User) error

Create create a user

func (*UserStore) Follow

func (s *UserStore) Follow(a *model.User, b *model.User) error

Follow create follow relashionship to User B from user A

func (*UserStore) GetByEmail

func (s *UserStore) GetByEmail(email string) (*model.User, error)

GetByEmail finds a user from email

func (*UserStore) GetByID

func (s *UserStore) GetByID(id uint) (*model.User, error)

GetByID finds a user from id

func (*UserStore) GetByUsername

func (s *UserStore) GetByUsername(username string) (*model.User, error)

GetByUsername finds a user from username

func (*UserStore) GetFollowingUserIDs

func (s *UserStore) GetFollowingUserIDs(m *model.User) ([]uint, error)

GetFollowingUserIDs returns user ids current user follows

func (*UserStore) IsFollowing

func (s *UserStore) IsFollowing(a *model.User, b *model.User) (bool, error)

IsFollowing returns whether user A follows user B or not

func (*UserStore) Unfollow

func (s *UserStore) Unfollow(a *model.User, b *model.User) error

Unfollow delete follow relashionship to User B from user A

func (*UserStore) Update

func (s *UserStore) Update(m *model.User) error

Update update all of user fields

Jump to

Keyboard shortcuts

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