Documentation ¶
Index ¶
- Constants
- type Database
- func (db *Database) AddNewTorrent(infoHash []byte, name string, files []File) error
- func (db *Database) Close() error
- func (db *Database) DoesTorrentExist(infoHash []byte) (bool, error)
- func (db *Database) GetFiles(infoHash []byte) ([]File, error)
- func (db *Database) GetNumberOfTorrents(ctx context.Context) (int, error)
- func (db *Database) GetTorrent(infoHash []byte) (*TorrentMetadata, error)
- func (db *Database) QueryTorrents(query string, orderBy OrderingCriteria, ascending bool, offset int) ([]TorrentMetadata, error)
- func (db *Database) QueryTorrentsCount(ctx context.Context, query string) (int, error)
- type File
- type OrderingCriteria
- type TorrentMetadata
Constants ¶
View Source
const (
// The maximum number of torrents to return in a single page.
MaxResults = 15
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database struct {
// contains filtered or unexported fields
}
func NewSqlite3Database ¶
func (*Database) AddNewTorrent ¶
func (*Database) DoesTorrentExist ¶
func (*Database) GetNumberOfTorrents ¶
Returns an approximate number of torrents in the database.
func (*Database) GetTorrent ¶
func (db *Database) GetTorrent(infoHash []byte) (*TorrentMetadata, error)
func (*Database) QueryTorrents ¶
func (db *Database) QueryTorrents( query string, orderBy OrderingCriteria, ascending bool, offset int, ) ([]TorrentMetadata, error)
type OrderingCriteria ¶
type OrderingCriteria uint8
const ( ByRelevance OrderingCriteria = iota ByName ByTotalSize ByDiscovered ByNFiles ByUpdatedOn )
type TorrentMetadata ¶
type TorrentMetadata struct { ID uint64 `json:"id"` InfoHash []byte `json:"infoHash"` // marshalled differently Name string `json:"name"` Size uint64 `json:"size"` CreatedAt int64 `json:"createdAt"` UpdatedAt int64 `json:"updatedAt"` NFiles uint `json:"nFiles"` Relevance float64 `json:"relevance"` }
Click to show internal directories.
Click to hide internal directories.