store

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

Functions

func NewBunDb

func NewBunDb(driver, dsn string) (*bun.DB, error)

Types

type Feed

type Feed struct {
	bun.BaseModel `bun:"table:feeds,alias:fe"`

	Id                  string     `bun:"id,pk"`
	UserId              string     `bun:"user_id"`
	Type                string     `bun:"type"`
	Title               string     `bun:"title"`
	Link                string     `bun:"link"`
	Authors             string     `bun:"authors"`
	Description         string     `bun:"description"`
	RssContent          string     `bun:"rss_content"`
	RssContentUpdatedAt ytime.Time `bun:"rss_content_updated_at"`
	RssUrl              string     `bun:"rss_url"`
	RssUrlUpdatedAt     ytime.Time `bun:"rss_url_updated_at"`
	CreatedAt           ytime.Time `bun:"created_at"`
	UpdatedAt           ytime.Time `bun:"updated_at"`
	DeletedAt           ytime.Time `bun:"deleted_at"`
}

type FeedFilter

type FeedFilter struct {
	Ids     []string
	UserIds []string
}

type File

type File struct {
	bun.BaseModel `bun:"table:files,alias:fi"`

	Id        string     `bun:"id,pk"`
	UserId    string     `bun:"user_id"`
	ItemId    *string    `bun:"item_id"`
	Size      int64      `bun:"size"`
	MimeType  string     `bun:"mime_type"`
	Hash      string     `bun:"hash"`
	UploadUrl string     `bun:"upload_url"`
	UploadId  string     `bun:"upload_id"`
	CreatedAt ytime.Time `bun:"created_at"`
	UpdatedAt ytime.Time `bun:"updated_at"`
	DeletedAt ytime.Time `bun:"deleted_at"`
}

type Item

type Item struct {
	bun.BaseModel `bun:"table:items,alias:it"`

	Id          string     `bun:"id,pk"`
	FeedId      string     `bun:"feed_id"`
	UserId      string     `bun:"user_id"`
	FileId      string     `bun:"file_id"`
	File        *File      `bun:"rel:belongs-to,join:file_id=id"`
	Title       string     `bun:"title"`
	Description string     `bun:"description"`
	Link        string     `bun:"link"`
	Authors     string     `bun:"authors"`
	CreatedAt   ytime.Time `bun:"created_at"`
	UpdatedAt   ytime.Time `bun:"updated_at"`
	DeletedAt   ytime.Time `bun:"deleted_at"`
	PublishedAt ytime.Time `bun:"published_at"`
}

type ItemFilter

type ItemFilter struct {
	Ids     []string
	FeedIds []string
	UserIds []string
}

type Migrator

type Migrator interface {
	Init(ctx context.Context) error
	Migrate(ctx context.Context) error
	Rollback(ctx context.Context) error
	Lock(ctx context.Context) error
	Unlock(ctx context.Context) error
	CreateSQLMigrations(ctx context.Context, name string) error
	Status(ctx context.Context) error
	MarkApplied(ctx context.Context) error
}

func NewBunMigrator

func NewBunMigrator(db *bun.DB) Migrator

type Store

type Store interface {
	Init(ctx context.Context) error

	GetFeeds(ctx context.Context, filter *FeedFilter) ([]*Feed, error)
	CreateFeeds(ctx context.Context, feeds []*Feed) error
	UpdateFeeds(ctx context.Context, feeds []*Feed, fields ...string) error

	GetItems(ctx context.Context, filter *ItemFilter) ([]*Item, error)
	CreateItems(ctx context.Context, items []*Item) error

	GetFileById(ctx context.Context, id string) (*File, error)
	CreateFile(ctx context.Context, file *File) error
	UpdateFiles(ctx context.Context, files []*File, fields ...string) error

	Tx(ctx context.Context, fn func(ctx context.Context) error) error
}

func NewBunStore

func NewBunStore(db *bun.DB) Store

Jump to

Keyboard shortcuts

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