db

package
v0.0.0-...-12f948b Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUserExists = errors.New("user already exists")

Functions

This section is empty.

Types

type DB

type DB interface {
	Init() error
	StoreTorrent(*model.Torrent, *metainfo.TorrentFile) error
	HasTorrent(ih [20]byte) (bool, error)
	FindTorrentByInfohash(ih [20]byte) (*model.Torrent, error)
	FindTorrentsWithTag(tag model.Tag) ([]model.Torrent, error)
	ListPopularTags(limit int) ([]model.Tag, error)
	GetTagByName(name string) (*model.Tag, error)
	GetTagByID(id uint64) (*model.Tag, error)
	GetCategoryByID(id int) (*model.Category, error)
	FindTorrentsInCategory(*model.Category, int, int) ([]model.Torrent, error)
	GetAllCategories() ([]model.Category, error)
	GetFrontPageTorrents() ([]model.Torrent, error)
	GetTorrentFiles(ih [20]byte) ([]model.File, error)
	CheckLogin(user, password string) (bool, error)
	AddUserLogin(username, password string) error
	DelUserLogin(username string) error
	InsertComment(text string, ih [20]byte) error
	GetCommentsForTorrent(*model.Torrent) ([]model.Comment, error)
	GetTorrentTags(*model.Torrent) ([]model.Tag, error)
	EnsureTags(tags []string) ([]model.Tag, error)
	AddTorrentTags(tags []model.Tag, t *model.Torrent) error
	DelTorrentTags(tags []model.Tag, t *model.Torrent) error
	AddCategory(name string) error
	DelCategory(name string) error
	DelTorrent(ih string) error
}

DB defines actions required by a database driver

type Postgres

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

PQTorrentStorage is a postgresql torrent metadata storage implementation

func NewPostgres

func NewPostgres(cfg *config.DBConfig) (db *Postgres, err error)

func (*Postgres) AddCategory

func (db *Postgres) AddCategory(name string) (err error)

func (*Postgres) AddTorrentTags

func (db *Postgres) AddTorrentTags(tags []model.Tag, t *model.Torrent) (err error)

func (*Postgres) AddUserLogin

func (db *Postgres) AddUserLogin(user, passwd string) (err error)

func (*Postgres) CheckLogin

func (db *Postgres) CheckLogin(user, passwd string) (authed bool, err error)

func (*Postgres) DelCategory

func (db *Postgres) DelCategory(name string) (err error)

func (*Postgres) DelTorrent

func (db *Postgres) DelTorrent(ih string) (err error)

func (*Postgres) DelTorrentTags

func (db *Postgres) DelTorrentTags(tags []model.Tag, t *model.Torrent) (err error)

func (*Postgres) DelUserLogin

func (db *Postgres) DelUserLogin(user string) (err error)

func (*Postgres) EnsureTags

func (db *Postgres) EnsureTags(tags []string) (ensured []model.Tag, err error)

func (*Postgres) FindTorrentByInfohash

func (st *Postgres) FindTorrentByInfohash(ih [20]byte) (t *model.Torrent, err error)

func (*Postgres) FindTorrentsInCategory

func (st *Postgres) FindTorrentsInCategory(cat *model.Category, perpage, offset int) (torrents []model.Torrent, err error)

func (*Postgres) FindTorrentsWithTag

func (st *Postgres) FindTorrentsWithTag(tag model.Tag) (torrents []model.Torrent, err error)

func (*Postgres) GetAllCategories

func (st *Postgres) GetAllCategories() (cats []model.Category, err error)

func (*Postgres) GetCategoryByID

func (st *Postgres) GetCategoryByID(id int) (cat *model.Category, err error)

func (*Postgres) GetCommentsForTorrent

func (db *Postgres) GetCommentsForTorrent(t *model.Torrent) (comments []model.Comment, err error)

func (*Postgres) GetFrontPageTorrents

func (st *Postgres) GetFrontPageTorrents() (torrents []model.Torrent, err error)

func (*Postgres) GetTagByID

func (st *Postgres) GetTagByID(id uint64) (tag *model.Tag, err error)

func (*Postgres) GetTagByName

func (st *Postgres) GetTagByName(name string) (tag *model.Tag, err error)

func (*Postgres) GetTorrentFiles

func (st *Postgres) GetTorrentFiles(ih [20]byte) (files []model.File, err error)

func (*Postgres) GetTorrentTags

func (db *Postgres) GetTorrentTags(t *model.Torrent) (tags []model.Tag, err error)

func (*Postgres) HasTorrent

func (db *Postgres) HasTorrent(ih [20]byte) (has bool, err error)

func (*Postgres) Init

func (st *Postgres) Init() (err error)

func (*Postgres) InsertComment

func (db *Postgres) InsertComment(text string, ih [20]byte) (err error)

func (*Postgres) ListPopularTags

func (st *Postgres) ListPopularTags(limit int) (tags []model.Tag, err error)

func (*Postgres) StoreTorrent

func (st *Postgres) StoreTorrent(t *model.Torrent, i *metainfo.TorrentFile) (err error)

Jump to

Keyboard shortcuts

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