Documentation ¶
Overview ¶
Package database is the implementation of the DatabaseInterface using SQLite3
Index ¶
- func RemoveDatabase()
- type DbIO
- func (db *DbIO) ChangeTrackedItemCompleteStatus(trackedItem *models.TrackedItem, complete bool)
- func (db *DbIO) CloseConnection()
- func (db *DbIO) CreateAccount(user string, password string, module models.ModuleInterface)
- func (db *DbIO) CreateCookie(name string, value string, expiration sql.NullTime, ...)
- func (db *DbIO) CreateOAuthClient(clientID string, clientSecret string, accessToken string, refreshToken string, ...)
- func (db *DbIO) CreateTrackedItem(uri string, module models.ModuleInterface)
- func (db *DbIO) DumpTables(writer io.Writer, tableNames ...string) (err error)
- func (db *DbIO) GetAccount(module models.ModuleInterface) *models.Account
- func (db *DbIO) GetAllAccounts(module models.ModuleInterface) (accounts []*models.Account)
- func (db *DbIO) GetAllCookies(module models.ModuleInterface) (cookies []*models.Cookie)
- func (db *DbIO) GetAllOAuthClients(module models.ModuleInterface) (oAuthClients []*models.OAuthClient)
- func (db *DbIO) GetCookie(name string, module models.ModuleInterface) *models.Cookie
- func (db *DbIO) GetFirstOrCreateAccount(user string, password string, module models.ModuleInterface) *models.Account
- func (db *DbIO) GetFirstOrCreateCookie(name string, value string, expirationString string, ...) *models.Cookie
- func (db *DbIO) GetFirstOrCreateOAuthClient(clientID string, clientSecret string, accessToken string, refreshToken string, ...) *models.OAuthClient
- func (db *DbIO) GetFirstOrCreateTrackedItem(uri string, module models.ModuleInterface) *models.TrackedItem
- func (db *DbIO) GetOAuthClient(module models.ModuleInterface) *models.OAuthClient
- func (db *DbIO) GetTrackedItems(module models.ModuleInterface, includeCompleted bool) []*models.TrackedItem
- func (db *DbIO) RestoreTableFromFile(fileName string) error
- func (db *DbIO) UpdateAccount(user string, password string, module models.ModuleInterface)
- func (db *DbIO) UpdateAccountDisabledStatus(user string, disabled bool, module models.ModuleInterface)
- func (db *DbIO) UpdateCookie(name string, value string, expirationString string, ...)
- func (db *DbIO) UpdateCookieDisabledStatus(name string, disabled bool, module models.ModuleInterface)
- func (db *DbIO) UpdateOAuthClient(clientID string, clientSecret string, accessToken string, refreshToken string, ...)
- func (db *DbIO) UpdateOAuthClientDisabledStatus(clientID string, accessToken string, disabled bool, ...)
- func (db *DbIO) UpdateTrackedItem(trackedItem *models.TrackedItem, currentItem string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RemoveDatabase ¶
func RemoveDatabase()
RemoveDatabase removes the currently set database, used primarily for unit tests
Types ¶
type DbIO ¶
type DbIO struct { models.DatabaseInterface // contains filtered or unexported fields }
DbIO implements the DatabaseInterface and contains the connection to the database
func NewConnection ¶
func NewConnection() *DbIO
NewConnection initializes the database DatabaseConnection to our sqlite file. Creates the database if the looked up file doesn't exist yet
func (*DbIO) ChangeTrackedItemCompleteStatus ¶
func (db *DbIO) ChangeTrackedItemCompleteStatus(trackedItem *models.TrackedItem, complete bool)
ChangeTrackedItemCompleteStatus changes the complete status of the passed tracked item in the database
func (*DbIO) CloseConnection ¶
func (db *DbIO) CloseConnection()
CloseConnection safely closes the database connection
func (*DbIO) CreateAccount ¶
func (db *DbIO) CreateAccount(user string, password string, module models.ModuleInterface)
CreateAccount inserts the passed user and password of the specific module into the database
func (*DbIO) CreateCookie ¶
func (db *DbIO) CreateCookie(name string, value string, expiration sql.NullTime, module models.ModuleInterface)
CreateCookie inserts the passed name, value and expiration of the specific module into the cookies table
func (*DbIO) CreateOAuthClient ¶
func (db *DbIO) CreateOAuthClient( clientID string, clientSecret string, accessToken string, refreshToken string, module models.ModuleInterface, )
CreateOAuthClient inserts the passed OAuth client details of the specific module into the database
func (*DbIO) CreateTrackedItem ¶
func (db *DbIO) CreateTrackedItem(uri string, module models.ModuleInterface)
CreateTrackedItem inserts the passed uri and the module into the tracked_items table
func (*DbIO) DumpTables ¶
DumpTables dumps the database tableSchema and the inserts to the passed writer
func (*DbIO) GetAccount ¶
func (db *DbIO) GetAccount(module models.ModuleInterface) *models.Account
GetAccount retrieves the first not disabled account of the passed module
func (*DbIO) GetAllAccounts ¶
func (db *DbIO) GetAllAccounts(module models.ModuleInterface) (accounts []*models.Account)
GetAllAccounts retrieves all accounts of only by module if module is not nil
func (*DbIO) GetAllCookies ¶
func (db *DbIO) GetAllCookies(module models.ModuleInterface) (cookies []*models.Cookie)
GetAllCookies retrieves all cookies of only by module if module is not nil
func (*DbIO) GetAllOAuthClients ¶
func (db *DbIO) GetAllOAuthClients(module models.ModuleInterface) (oAuthClients []*models.OAuthClient)
GetAllOAuthClients retrieves all OAuth clients of only by module if module is not nil
func (*DbIO) GetCookie ¶
GetCookie retrieves a specific cookie associated to the passed module which is not expired or disabled
func (*DbIO) GetFirstOrCreateAccount ¶
func (db *DbIO) GetFirstOrCreateAccount(user string, password string, module models.ModuleInterface) *models.Account
GetFirstOrCreateAccount checks if an account exists already, else creates it returns the already persisted or the newly created account
func (*DbIO) GetFirstOrCreateCookie ¶
func (db *DbIO) GetFirstOrCreateCookie( name string, value string, expirationString string, module models.ModuleInterface, ) *models.Cookie
GetFirstOrCreateCookie checks if a cookie exists already, else creates it returns the already persisted or the newly created cookie
func (*DbIO) GetFirstOrCreateOAuthClient ¶
func (db *DbIO) GetFirstOrCreateOAuthClient( clientID string, clientSecret string, accessToken string, refreshToken string, module models.ModuleInterface, ) *models.OAuthClient
GetFirstOrCreateOAuthClient checks if an OAuth client exists already, else creates it returns the already persisted or the newly created OAuth client
func (*DbIO) GetFirstOrCreateTrackedItem ¶
func (db *DbIO) GetFirstOrCreateTrackedItem(uri string, module models.ModuleInterface) *models.TrackedItem
GetFirstOrCreateTrackedItem checks if an item exists already, else creates it returns the already persisted or the newly created item
func (*DbIO) GetOAuthClient ¶
func (db *DbIO) GetOAuthClient(module models.ModuleInterface) *models.OAuthClient
GetOAuthClient retrieves the first not disabled OAuth client of the passed module
func (*DbIO) GetTrackedItems ¶
func (db *DbIO) GetTrackedItems(module models.ModuleInterface, includeCompleted bool) []*models.TrackedItem
GetTrackedItems retrieves all tracked items from the sqlite database if module is set limit the results use the passed module as restraint
func (*DbIO) RestoreTableFromFile ¶
RestoreTableFromFile executes the passed SQL file, used primarily for restoration #nosec
func (*DbIO) UpdateAccount ¶
func (db *DbIO) UpdateAccount(user string, password string, module models.ModuleInterface)
UpdateAccount updates the password of the passed user/module entry
func (*DbIO) UpdateAccountDisabledStatus ¶
func (db *DbIO) UpdateAccountDisabledStatus(user string, disabled bool, module models.ModuleInterface)
UpdateAccountDisabledStatus disables the account of the passed user/module
func (*DbIO) UpdateCookie ¶
func (db *DbIO) UpdateCookie(name string, value string, expirationString string, module models.ModuleInterface)
UpdateCookie updates the value and/or the expiration date of the passed name/module associated cookie
func (*DbIO) UpdateCookieDisabledStatus ¶
func (db *DbIO) UpdateCookieDisabledStatus(name string, disabled bool, module models.ModuleInterface)
UpdateCookieDisabledStatus disables or enables the cookie of the passed user/module
func (*DbIO) UpdateOAuthClient ¶
func (db *DbIO) UpdateOAuthClient( clientID string, clientSecret string, accessToken string, refreshToken string, module models.ModuleInterface, )
UpdateOAuthClient updates the OAuth client of the passed client ID & module updating static token sources is currently not supported, disabling and adding a new one would make more sense
func (*DbIO) UpdateOAuthClientDisabledStatus ¶
func (db *DbIO) UpdateOAuthClientDisabledStatus( clientID string, accessToken string, disabled bool, module models.ModuleInterface, )
UpdateOAuthClientDisabledStatus disables the OAuth client of the passed client ID/module
func (*DbIO) UpdateTrackedItem ¶
func (db *DbIO) UpdateTrackedItem(trackedItem *models.TrackedItem, currentItem string)
UpdateTrackedItem updates the current item column of the tracked item in the database also sets the complete status to false to check it on the next check cycle