storage

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRecordNotFound record not found error
	ErrRecordNotFound = errors.New("record not found")
)

Functions

This section is empty.

Types

type Content

type Content interface {
	Storage
	// AddContent adds a new article
	AddContent(ctx context.Context, content *model.Content) error
	// DeleteSourceContents deletes all articles of a subscription source and returns the number of deleted articles
	DeleteSourceContents(ctx context.Context, sourceID uint) (int64, error)
	// HashIDExist checks if an article with the given hash id already exists
	HashIDExist(ctx context.Context, hashID string) (bool, error)
}

type ContentStorageImpl

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

func NewContentStorageImpl

func NewContentStorageImpl(db *gorm.DB) *ContentStorageImpl

func (*ContentStorageImpl) AddContent

func (s *ContentStorageImpl) AddContent(ctx context.Context, content *model.Content) error

func (*ContentStorageImpl) DeleteSourceContents

func (s *ContentStorageImpl) DeleteSourceContents(ctx context.Context, sourceID uint) (int64, error)

func (*ContentStorageImpl) HashIDExist

func (s *ContentStorageImpl) HashIDExist(ctx context.Context, hashID string) (bool, error)

func (*ContentStorageImpl) Init

func (s *ContentStorageImpl) Init(ctx context.Context) error

type GetSubscriptionsOptions

type GetSubscriptionsOptions struct {
	Count    int // Number of items to retrieve, -1 to retrieve all
	Offset   int
	SortType SubscriptionSortType
}

type GetSubscriptionsResult

type GetSubscriptionsResult struct {
	Subscriptions []*model.Subscribe
	HasMore       bool
}

type Source

type Source interface {
	Storage
	AddSource(ctx context.Context, source *model.Source) error
	GetSource(ctx context.Context, id uint) (*model.Source, error)
	GetSources(ctx context.Context) ([]*model.Source, error)
	GetSourceByURL(ctx context.Context, url string) (*model.Source, error)
	Delete(ctx context.Context, id uint) error
	UpsertSource(ctx context.Context, sourceID uint, newSource *model.Source) error
}

Source subscription source storage interface

type SourceStorageImpl

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

func NewSourceStorageImpl

func NewSourceStorageImpl(db *gorm.DB) *SourceStorageImpl

func (*SourceStorageImpl) AddSource

func (s *SourceStorageImpl) AddSource(ctx context.Context, source *model.Source) error

func (*SourceStorageImpl) Delete

func (s *SourceStorageImpl) Delete(ctx context.Context, id uint) error

func (*SourceStorageImpl) GetSource

func (s *SourceStorageImpl) GetSource(ctx context.Context, id uint) (*model.Source, error)

func (*SourceStorageImpl) GetSourceByURL

func (s *SourceStorageImpl) GetSourceByURL(ctx context.Context, url string) (*model.Source, error)

func (*SourceStorageImpl) GetSources

func (s *SourceStorageImpl) GetSources(ctx context.Context) ([]*model.Source, error)

func (*SourceStorageImpl) Init

func (s *SourceStorageImpl) Init(ctx context.Context) error

func (*SourceStorageImpl) UpsertSource

func (s *SourceStorageImpl) UpsertSource(ctx context.Context, sourceID uint, newSource *model.Source) error

type Storage

type Storage interface {
	Init(ctx context.Context) error
}

type Subscription

type Subscription interface {
	Storage
	AddSubscription(ctx context.Context, subscription *model.Subscribe) error
	SubscriptionExist(ctx context.Context, userID int64, sourceID uint) (bool, error)
	GetSubscription(ctx context.Context, userID int64, sourceID uint) (*model.Subscribe, error)
	GetSubscriptionsByUserID(
		ctx context.Context, userID int64, opts *GetSubscriptionsOptions,
	) (*GetSubscriptionsResult, error)
	GetSubscriptionsBySourceID(
		ctx context.Context, sourceID uint, opts *GetSubscriptionsOptions,
	) (*GetSubscriptionsResult, error)
	CountSubscriptions(ctx context.Context) (int64, error)
	DeleteSubscription(ctx context.Context, userID int64, sourceID uint) (int64, error)
	CountSourceSubscriptions(ctx context.Context, sourceID uint) (int64, error)
	UpdateSubscription(
		ctx context.Context, userID int64, sourceID uint, newSubscription *model.Subscribe,
	) error
	UpsertSubscription(
		ctx context.Context, userID int64, sourceID uint, newSubscription *model.Subscribe,
	) error
}

type SubscriptionSortType

type SubscriptionSortType = int
const (
	SubscriptionSortTypeCreatedTimeDesc SubscriptionSortType = iota
)

type SubscriptionStorageImpl

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

func NewSubscriptionStorageImpl

func NewSubscriptionStorageImpl(db *gorm.DB) *SubscriptionStorageImpl

func (*SubscriptionStorageImpl) AddSubscription

func (s *SubscriptionStorageImpl) AddSubscription(ctx context.Context, subscription *model.Subscribe) error

func (*SubscriptionStorageImpl) CountSourceSubscriptions

func (s *SubscriptionStorageImpl) CountSourceSubscriptions(ctx context.Context, sourceID uint) (int64, error)

func (*SubscriptionStorageImpl) CountSubscriptions

func (s *SubscriptionStorageImpl) CountSubscriptions(ctx context.Context) (int64, error)

func (*SubscriptionStorageImpl) DeleteSubscription

func (s *SubscriptionStorageImpl) DeleteSubscription(ctx context.Context, userID int64, sourceID uint) (int64, error)

func (*SubscriptionStorageImpl) GetSubscription

func (s *SubscriptionStorageImpl) GetSubscription(ctx context.Context, userID int64, sourceID uint) (
	*model.Subscribe, error,
)

func (*SubscriptionStorageImpl) GetSubscriptionsBySourceID

func (s *SubscriptionStorageImpl) GetSubscriptionsBySourceID(
	ctx context.Context, sourceID uint, opts *GetSubscriptionsOptions,
) (*GetSubscriptionsResult, error)

func (*SubscriptionStorageImpl) GetSubscriptionsByUserID

func (s *SubscriptionStorageImpl) GetSubscriptionsByUserID(
	ctx context.Context, userID int64, opts *GetSubscriptionsOptions,
) (*GetSubscriptionsResult, error)

func (*SubscriptionStorageImpl) Init

func (*SubscriptionStorageImpl) SubscriptionExist

func (s *SubscriptionStorageImpl) SubscriptionExist(ctx context.Context, userID int64, sourceID uint) (bool, error)

func (*SubscriptionStorageImpl) UpdateSubscription

func (s *SubscriptionStorageImpl) UpdateSubscription(
	ctx context.Context, userID int64, sourceID uint, newSubscription *model.Subscribe,
) error

func (*SubscriptionStorageImpl) UpsertSubscription

func (s *SubscriptionStorageImpl) UpsertSubscription(
	ctx context.Context, userID int64, sourceID uint, newSubscription *model.Subscribe,
) error

type User

type User interface {
	Storage
	CreateUser(ctx context.Context, user *model.User) error
	GetUser(ctx context.Context, id int64) (*model.User, error)
}

User user storage interface

type UserStorageImpl

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

func NewUserStorageImpl

func NewUserStorageImpl(db *gorm.DB) *UserStorageImpl

func (*UserStorageImpl) CrateUser

func (s *UserStorageImpl) CrateUser(ctx context.Context, user *model.User) error

func (*UserStorageImpl) CreateUser

func (*UserStorageImpl) CreateUser(ctx context.Context, user *model.User) error

CreateUser implements User.

func (*UserStorageImpl) GetUser

func (s *UserStorageImpl) GetUser(ctx context.Context, id int64) (*model.User, error)

func (*UserStorageImpl) Init

func (s *UserStorageImpl) Init(ctx context.Context) error

Directories

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

Jump to

Keyboard shortcuts

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