db

package
v0.0.0-...-4cc00cf Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2017 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIToken

type APIToken struct {
	Token     string
	CreatedAt time.Time
	User      User
}

type Artist

type Artist struct {
	ID            int
	Name          string
	Aliases       []ArtistAlias
	ReleaseGroups []RoledReleaseGroup
	Added         time.Time
	AddedBy       User
	Bio           sql.NullString
	Tags          []string
}

type ArtistAlias

type ArtistAlias struct {
	Alias   string
	Added   time.Time
	AddedBy User
}

type BlogEntry

type BlogEntry struct {
	ID       int
	Author   User
	Title    string
	PostedAt time.Time
	Content  string
	Tags     []string
}

type BoilingDB

type BoilingDB interface {
	Close() error

	SignUpUser(username, password, email string) error
	LoginAndGetUser(username, password string) (*User, error)
	GetUser(id int) (*User, error)
	UpdateUserDeltaUpDown(id, deltaUp, deltaDown int) error
	UpdateUserSetLastAccess(id int, lastAccess time.Time) error
	UpdateUserSetLastLogin(id int, lastLogin time.Time) error
	UpdateUserAddPrivileges(id int, privileges []int) error
	PopulateUserPrivileges(u *User) error

	GetPasskeyForUser(id int) (*Passkey, error)
	GetAllPasskeysForUser(id int) ([]Passkey, error)
	GenerateNewPasskeyForUser(id int) (string, error)

	InsertTokenForUser(u User) (*APIToken, error)
	GetToken(token string) (*APIToken, error)

	InsertBlogEntry(post *BlogEntry) error
	GetBlogEntry(id int) (*BlogEntry, error)
	UpdateBlogEntry(post BlogEntry) error
	DeleteBlogEntry(id int) error
	GetBlogEntries(limit, offset int) ([]BlogEntry, error)

	AutocompleteArtists(s string) ([]Artist, error)
	AutocompleteArtistTags(s string) ([]string, error)
	GetArtist(id int) (*Artist, error)
	PopulateReleaseGroups(artist *Artist) error
	InsertArtist(artist *Artist) error

	GetAllPrivileges() (map[int]string, error)

	GetAllFormats() (map[int]Format, error)

	GetAllMedia() (map[int]string, error)

	GetAllReleaseGroupRoles() (map[int]string, error)

	GetAllLeechTypes() (map[int]string, error)

	GetAllReleaseProperties() (map[int]string, error)
	AddReleaseProperty(key string) error

	AutocompleteRecordLabels(s string) ([]RecordLabel, error)
	GetRecordLabel(id int) (*RecordLabel, error)
	InsertRecordLabel(label *RecordLabel) error

	AutocompleteReleaseTags(s string) ([]string, error)
	InsertRelease(release *Release) error
	SetReleaseProperty(id int, k, v string) error
	GetRelease(id int) (*Release, error)
	DeleteRelease(id int) error
	PopulateTorrents(release *Release) error

	AutocompleteReleaseGroups(s string) ([]ReleaseGroup, error)
	AutocompleteReleaseGroupTags(s string) ([]string, error)
	GetAllReleaseGroupTypes() (map[int]string, error)
	GetReleaseGroup(id int) (*ReleaseGroup, error)
	InsertReleaseGroup(group *ReleaseGroup) error
	PopulateReleases(group *ReleaseGroup) error
	SearchReleaseGroups(q *Query, offset, limit int) ([]ReleaseGroup, error)
}

func New

func New(database, user, pass string) (BoilingDB, error)

type Boolean

type Boolean interface {
	// contains filtered or unexported methods
}

func And

func And(b1, b2 Boolean) Boolean

func Eq

func Eq(column ColumnSelector, v interface{}) Boolean

func Neq

func Neq(column ColumnSelector, v interface{}) Boolean

func Or

func Or(b1, b2 Boolean) Boolean

type ColumnSelector

type ColumnSelector interface {
	// contains filtered or unexported methods
}

func ReleaseGroupAddedSelector

func ReleaseGroupAddedSelector() ColumnSelector

func ReleaseGroupReleaseDateSelector

func ReleaseGroupReleaseDateSelector() ColumnSelector

func ReleaseGroupTypeSelector

func ReleaseGroupTypeSelector() ColumnSelector

type DB

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

func (*DB) AddReleaseProperty

func (db *DB) AddReleaseProperty(key string) error

func (*DB) AutocompleteArtistTags

func (db *DB) AutocompleteArtistTags(s string) ([]string, error)

func (*DB) AutocompleteArtists

func (db *DB) AutocompleteArtists(s string) ([]Artist, error)

func (*DB) AutocompleteRecordLabels

func (db *DB) AutocompleteRecordLabels(s string) ([]RecordLabel, error)

func (*DB) AutocompleteReleaseGroupTags

func (db *DB) AutocompleteReleaseGroupTags(s string) ([]string, error)

func (*DB) AutocompleteReleaseGroups

func (db *DB) AutocompleteReleaseGroups(s string) ([]ReleaseGroup, error)

func (*DB) AutocompleteReleaseTags

func (db *DB) AutocompleteReleaseTags(s string) ([]string, error)

func (*DB) Close

func (db *DB) Close() error

func (*DB) DeleteBlogEntry

func (db *DB) DeleteBlogEntry(id int) error

func (*DB) DeleteRelease

func (db *DB) DeleteRelease(id int) error

func (*DB) DeleteTorrent

func (db *DB) DeleteTorrent(id int) error

func (*DB) GenerateNewPasskeyForUser

func (db *DB) GenerateNewPasskeyForUser(id int) (string, error)

func (*DB) GetAllFormats

func (db *DB) GetAllFormats() (map[int]Format, error)

func (*DB) GetAllLeechTypes

func (db *DB) GetAllLeechTypes() (map[int]string, error)

func (*DB) GetAllMedia

func (db *DB) GetAllMedia() (map[int]string, error)

func (*DB) GetAllPasskeysForUser

func (db *DB) GetAllPasskeysForUser(id int) ([]Passkey, error)

func (*DB) GetAllPrivileges

func (db *DB) GetAllPrivileges() (map[int]string, error)

func (*DB) GetAllReleaseGroupRoles

func (db *DB) GetAllReleaseGroupRoles() (map[int]string, error)

func (*DB) GetAllReleaseGroupTypes

func (db *DB) GetAllReleaseGroupTypes() (map[int]string, error)

func (*DB) GetAllReleaseProperties

func (db *DB) GetAllReleaseProperties() (map[int]string, error)

func (*DB) GetArtist

func (db *DB) GetArtist(id int) (*Artist, error)

func (*DB) GetBlogEntries

func (db *DB) GetBlogEntries(limit, offset int) ([]BlogEntry, error)

func (*DB) GetBlogEntry

func (db *DB) GetBlogEntry(id int) (*BlogEntry, error)

func (*DB) GetPasskeyForUser

func (db *DB) GetPasskeyForUser(id int) (*Passkey, error)

func (*DB) GetRecordLabel

func (db *DB) GetRecordLabel(id int) (*RecordLabel, error)

func (*DB) GetRelease

func (db *DB) GetRelease(id int) (*Release, error)

func (*DB) GetReleaseGroup

func (db *DB) GetReleaseGroup(id int) (*ReleaseGroup, error)

func (*DB) GetToken

func (db *DB) GetToken(token string) (*APIToken, error)

func (*DB) GetTorrent

func (db *DB) GetTorrent(id int) (*Torrent, error)

func (*DB) GetUser

func (db *DB) GetUser(id int) (*User, error)

func (*DB) InsertArtist

func (db *DB) InsertArtist(artist *Artist) error

func (*DB) InsertBlogEntry

func (db *DB) InsertBlogEntry(post *BlogEntry) error

func (*DB) InsertRecordLabel

func (db *DB) InsertRecordLabel(label *RecordLabel) error

func (*DB) InsertRelease

func (db *DB) InsertRelease(release *Release) error

func (*DB) InsertReleaseGroup

func (db *DB) InsertReleaseGroup(group *ReleaseGroup) error

func (*DB) InsertTokenForUser

func (db *DB) InsertTokenForUser(u User) (*APIToken, error)

func (*DB) InsertTorrent

func (db *DB) InsertTorrent(torrent *Torrent) error

func (*DB) LoginAndGetUser

func (db *DB) LoginAndGetUser(username, password string) (*User, error)

func (*DB) PopulateReleaseGroups

func (db *DB) PopulateReleaseGroups(artist *Artist) error

func (*DB) PopulateReleases

func (db *DB) PopulateReleases(group *ReleaseGroup) error

func (*DB) PopulateTorrents

func (db *DB) PopulateTorrents(release *Release) error

func (*DB) PopulateUserPrivileges

func (db *DB) PopulateUserPrivileges(u *User) error

func (*DB) SearchReleaseGroups

func (db *DB) SearchReleaseGroups(q *Query, offset, limit int) ([]ReleaseGroup, error)

func (*DB) SetReleaseProperty

func (db *DB) SetReleaseProperty(id int, k, v string) error

func (*DB) SignUpUser

func (db *DB) SignUpUser(username, password, email string) error

func (*DB) UpdateBlogEntry

func (db *DB) UpdateBlogEntry(post BlogEntry) error

func (*DB) UpdateUserAddPrivileges

func (db *DB) UpdateUserAddPrivileges(id int, privileges []int) error

func (*DB) UpdateUserDeltaUpDown

func (db *DB) UpdateUserDeltaUpDown(id, deltaUp, deltaDown int) error

func (*DB) UpdateUserSetLastAccess

func (db *DB) UpdateUserSetLastAccess(id int, lastAccess time.Time) error

func (*DB) UpdateUserSetLastLogin

func (db *DB) UpdateUserSetLastLogin(id int, lastLogin time.Time) error

type Format

type Format struct {
	Format   string
	Encoding string
}

type Passkey

type Passkey struct {
	Uid       int
	Passkey   string
	CreatedAt time.Time
	Valid     bool
}

type Query

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

func NewQuery

func NewQuery(b Boolean) *Query

func (*Query) Build

func (q *Query) Build() (string, []interface{})

func (*Query) SetSorter

func (q *Query) SetSorter(s Sorter)

type RecordLabel

type RecordLabel struct {
	ID          int
	Name        string
	Description sql.NullString
	Founded     pq.NullTime
	Added       time.Time
	AddedBy     User
}

type Release

type Release struct {
	ID              int
	ReleaseGroup    ReleaseGroup
	Edition         sql.NullString
	Medium          int
	ReleaseDate     time.Time
	CatalogueNumber sql.NullString
	RecordLabel     RecordLabel
	Torrents        []Torrent
	Added           time.Time
	AddedBy         User
	Original        bool
	Tags            []string

	// Properties lists "official" properties of releases, for example
	// "LossyMasterApproved", to be set by trusted users or staff.
	Properties map[string]string
}

type ReleaseGroup

type ReleaseGroup struct {
	ID          int
	Name        string // Album title
	Artists     []RoledArtist
	ReleaseDate time.Time
	Added       time.Time
	AddedBy     User
	Type        int       // Album/EP
	Releases    []Release // individual releases
	Tags        []string
}

type RoledArtist

type RoledArtist struct {
	Role   int
	Artist Artist
}

type RoledReleaseGroup

type RoledReleaseGroup struct {
	Role         int
	ReleaseGroup ReleaseGroup
}

type Sorter

type Sorter interface {
	// contains filtered or unexported methods
}

func SortAscending

func SortAscending(column ColumnSelector) Sorter

func SortDescending

func SortDescending(column ColumnSelector) Sorter

type Torrent

type Torrent struct {
	ID         int
	Uploaded   time.Time
	UploadedBy User
	InfoHash   [20]byte

	Format      int
	Size        int64
	Description string

	Leechers int
	Seeders  int
	Snatches int

	FileList []string

	Properties map[string]string
	LeechType  string
}

type User

type User struct {
	ID           int
	Username     string
	Email        string
	PasswordHash string
	Bio          sql.NullString
	Enabled      bool
	CanLogin     bool
	JoinedAt     time.Time
	LastLogin    pq.NullTime
	LastAccess   pq.NullTime
	Uploaded     int64
	Downloaded   int64
	Privileges   []int
}

Jump to

Keyboard shortcuts

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