Documentation ¶
Overview ¶
db contains the low level database logic access for Armaria
Index ¶
- func AddBook(tx Transaction, url string, name string, description null.NullString, ...) (string, error)
- func AddFolder(tx Transaction, name string, parentID null.NullString, order string) (string, error)
- func AddTags(tx Transaction, tags []string) error
- func BookFolderExists(tx Transaction, ID string, isFolder bool) (bool, error)
- func CleanOrphanedTags(tx Transaction, tags []string) error
- func ExecWithTransaction(inputPath null.NullString, configPath string, execFn ExecTxFn) (err error)
- func GetBookFolderParents(tx Transaction, ID string) ([]string, error)
- func GetBooks(tx Transaction, args GetBooksArgs) ([]armaria.Book, error)
- func GetParentAndChildren(tx Transaction, ID string) ([]armaria.Book, error)
- func GetTags(tx Transaction, args GetTagsArgs) ([]string, error)
- func LinkTags(tx Transaction, bookmarkID string, tags []string) error
- func MaxOrder(tx Transaction, parentID null.NullString) (string, error)
- func QueryWithDB[T any](inputPath null.NullString, configPath string, queryFn QueryTxFn[T]) (T, error)
- func QueryWithTransaction[T any](inputPath null.NullString, configPath string, queryFn QueryTxFn[T]) (val T, err error)
- func RemoveBook(tx Transaction, ID string) error
- func RemoveFolder(tx Transaction, ID string) error
- func UnlinkTags(tx Transaction, ID string, tags []string) error
- func UpdateBook(tx Transaction, ID string, args UpdateBookArgs) error
- func UpdateFolder(tx Transaction, ID string, args UpdateFolderArgs) error
- type ExecTxFn
- type GetBooksArgs
- type GetTagsArgs
- type QueryTxFn
- type Transaction
- type UpdateBookArgs
- type UpdateFolderArgs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddBook ¶
func AddBook(tx Transaction, url string, name string, description null.NullString, parentID null.NullString, order string) (string, error)
AddBook inserts a book into the bookmarks database.
func AddFolder ¶
func AddFolder(tx Transaction, name string, parentID null.NullString, order string) (string, error)
AddFolder inserts a folder into the bookmarks database.
func AddTags ¶
func AddTags(tx Transaction, tags []string) error
AddTags inserts tags into the bookmarks database.
func BookFolderExists ¶
func BookFolderExists(tx Transaction, ID string, isFolder bool) (bool, error)
BookFolderExists returns true if the target book or folder exists.
func CleanOrphanedTags ¶
func CleanOrphanedTags(tx Transaction, tags []string) error
CleanOrphanedTags removes any tags that aren't applied to a bookmark.
func ExecWithTransaction ¶
func ExecWithTransaction(inputPath null.NullString, configPath string, execFn ExecTxFn) (err error)
execWithTransaction creates a scope for functions that operate on a transaction which doesn't return results. Handles connecting to the DB, creating the transaction, committing/rolling back, and closing the connection. Will also handle creating the DB if it doesn't exist and applying missing migrations to it.
func GetBookFolderParents ¶ added in v0.0.17
func GetBookFolderParents(tx Transaction, ID string) ([]string, error)
GetBookFolderParents returns the parent names of a bookmark or folder.
func GetBooks ¶
func GetBooks(tx Transaction, args GetBooksArgs) ([]armaria.Book, error)
GetBooks lists bookmarks/folders in the bookmarks DB.
func GetParentAndChildren ¶
func GetParentAndChildren(tx Transaction, ID string) ([]armaria.Book, error)
GetParentAndChildren gets a parent and all of its children.
func GetTags ¶
func GetTags(tx Transaction, args GetTagsArgs) ([]string, error)
GetTags lists tags in the bookmarks DB.
func LinkTags ¶
func LinkTags(tx Transaction, bookmarkID string, tags []string) error
LinkTags adds tags to bookmark.
func MaxOrder ¶ added in v0.0.22
func MaxOrder(tx Transaction, parentID null.NullString) (string, error)
MaxOrder returns the max order for a given parentID.
func QueryWithDB ¶
func QueryWithDB[T any](inputPath null.NullString, configPath string, queryFn QueryTxFn[T]) (T, error)
QueryWithDB creates a scope for for functions that operate on a database connection which return results. Handles connecting to the DB and closing the connection. Will also handle creating the DB if it doesn't exist and applying missing migrations to it.
func QueryWithTransaction ¶
func QueryWithTransaction[T any](inputPath null.NullString, configPath string, queryFn QueryTxFn[T]) (val T, err error)
queryWithTransaction creates a scope for functions that operate on a transaction which returns results. Handles connecting to the DB, creating the transaction, committing/rolling back, and closing the connection. Will also handle creating the DB if it doesn't exist and applying missing migrations to it.
func RemoveBook ¶
func RemoveBook(tx Transaction, ID string) error
RemoveBook deletes a bookmark from the bookmarks DB.
func RemoveFolder ¶
func RemoveFolder(tx Transaction, ID string) error
RemoveFolder deletes a folder from the bookmarks DB.
func UnlinkTags ¶
func UnlinkTags(tx Transaction, ID string, tags []string) error
UnlinkTags removes tags from a bookmark.
func UpdateBook ¶
func UpdateBook(tx Transaction, ID string, args UpdateBookArgs) error
UpdateBook updates a book in the bookmarks database.
func UpdateFolder ¶
func UpdateFolder(tx Transaction, ID string, args UpdateFolderArgs) error
UpdateFolder updates a folder in the bookmarks database.
Types ¶
type ExecTxFn ¶
type ExecTxFn func(Transaction) error
ExecTxFn is a function that operates on a transaction which doesn't return results.
type GetBooksArgs ¶
type GetBooksArgs struct { IDFilter string IncludeBooks bool IncludeFolders bool ParentID null.NullString Query null.NullString Tags []string After null.NullString Order armaria.Order Direction armaria.Direction First null.NullInt64 }
GetBooksArgs are the args for getBooksDB.
type GetTagsArgs ¶
type GetTagsArgs struct { IDFilter null.NullString TagsFilter []string Query null.NullString After null.NullString Direction armaria.Direction First null.NullInt64 }
GetTagsArgs are the args for getTagsDB.
type QueryTxFn ¶
type QueryTxFn[T any] func(Transaction) (T, error)
QueryTxFn is a function that operates on a transaction which returns results.
type Transaction ¶
type Transaction interface { Exec(query string, args ...interface{}) (sql.Result, error) Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
Transaction represents a database/sql connection.
type UpdateBookArgs ¶
type UpdateBookArgs struct { Name null.NullString URL null.NullString Description null.NullString ParentID null.NullString Order string }
UpdateBookArgs are the args for updateBookDB.
type UpdateFolderArgs ¶
type UpdateFolderArgs struct { Name null.NullString ParentID null.NullString Order string }
UpdateFolderArgs are the args for updateFolderDB.