Documentation ¶
Index ¶
- Variables
- func GroupByHash[T model.IEntry](entries []T) (map[string]T, []string, error)
- func NewStorage[T model.IEntry](db *sql.DB, opt Options) (storage.Storage[T], error)
- func Open(ctx context.Context, conf Options) (*sql.DB, error)
- func Where[T model.IEntry](where storage.WhereOptions, has bool, entry DBEntry[T]) bool
- type DBEntry
- type DBEntryToUpdate
- type Options
- type Storage
- func (s Storage[T]) Cleanup() (int64, error)
- func (s Storage[T]) FindByHasStory(opt storage.FindByHasStoryOptions) ([]T, error)
- func (s Storage[T]) FindByHash(hash string) (T, error)
- func (s Storage[T]) Has(hash string) (bool, error)
- func (s Storage[T]) Store(entry storage.Entry[T]) error
- func (s Storage[T]) Update(entry storage.Entry[T]) error
- func (s Storage[T]) Where(where storage.WhereOptions, list []T) ([]T, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrFailToOpenDatabase = apperrors.System(nil, "fail to open database: %s", "DB:FAIL_TO_OPEN_DATABASE") ErrFailToRunMigration = apperrors.System(nil, "fail to run migration", "DB:FAIL_TO_RUN_MIGRATION") ErrDatabaseMustBeFile = apperrors.Business("database must be a file: %s", "DB:DATABASE_MUST_BE_FILE") ErrDatabaseMustExist = apperrors.Business("database file must exist: %s", "DB:DATABASE_MUST_EXIST") )
View Source
var ErrFailedToCreateEntry = apperrors.System(nil, "failed to create entry", "DB:FailedToCreateEntry")
Functions ¶
func NewStorage ¶
Types ¶
type DBEntry ¶
type DBEntry[T model.IEntry] struct { Hash string `db:"hash,primarykey"` SourceName string `db:"source_name"` ImageURL string `db:"image_url"` Text string `db:"text"` Categories []byte `db:"categories"` URL string `db:"url"` Status storage.Status `db:"status"` CreatedAt time.Time `db:"created_at"` HasStory bool `db:"has_story"` TTL time.Time `db:"ttl"` }
type DBEntryToUpdate ¶
type DBEntryToUpdate[T model.IEntry] struct { Hash string `db:"hash,primarykey"` Status storage.Status `db:"status"` HasStory bool `db:"has_story"` }
func EntryToUpdate ¶
type Storage ¶
func (Storage[T]) FindByHasStory ¶
func (s Storage[T]) FindByHasStory(opt storage.FindByHasStoryOptions) ([]T, error)
func (Storage[T]) FindByHash ¶
Click to show internal directories.
Click to hide internal directories.