Documentation ¶
Index ¶
- type Database
- type XormDatabase
- func (db *XormDatabase) CreateAccount(username, password string) error
- func (db *XormDatabase) DeleteAccounts(usernames ...string) error
- func (db *XormDatabase) DeleteBookmarks(ids ...int) error
- func (db *XormDatabase) GetAccount(username string) (model.Account, error)
- func (db *XormDatabase) GetAccounts(keyword string) ([]model.Account, error)
- func (db *XormDatabase) GetBookmarkID(url string) int
- func (db *XormDatabase) GetBookmarks(withContent bool, ids ...int) ([]model.Bookmark, error)
- func (db *XormDatabase) GetTags() ([]model.Tag, error)
- func (db *XormDatabase) InsertBookmark(bookmark *model.Bookmark) error
- func (db *XormDatabase) SearchBookmarks(orderLatest bool, keyword string, tags ...string) ([]model.Bookmark, error)
- func (db *XormDatabase) UpdateBookmarks(bookmarks ...model.Bookmark) (result []model.Bookmark, err error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
type Database interface { // InsertBookmark inserts new bookmark to database. InsertBookmark(bookmark *model.Bookmark) error // GetBookmarks fetch list of bookmarks based on submitted ids. GetBookmarks(withContent bool, ids ...int) ([]model.Bookmark, error) // GetTags fetch list of tags and their frequency GetTags() ([]model.Tag, error) // DeleteBookmarks removes all record with matching ids from database. DeleteBookmarks(ids ...int) error // SearchBookmarks search bookmarks by the keyword or tags. SearchBookmarks(orderLatest bool, keyword string, tags ...string) ([]model.Bookmark, error) // UpdateBookmarks updates the saved bookmark in database. UpdateBookmarks(bookmarks ...model.Bookmark) ([]model.Bookmark, error) // CreateAccount creates new account in database CreateAccount(username, password string) error // GetAccount fetch account with matching username GetAccount(username string) (model.Account, error) // GetAccounts fetch list of accounts with matching keyword GetAccounts(keyword string) ([]model.Account, error) // DeleteAccounts removes all record with matching usernames DeleteAccounts(usernames ...string) error // GetBookmarkID fetchs bookmark ID based by its url GetBookmarkID(url string) int }
Database is interface for manipulating data in database.
type XormDatabase ¶
SQLiteDatabase is implementation of Database interface for connecting to SQLite3 database.
func OpenXormDatabase ¶
func OpenXormDatabase(dsn, dbType string) (*XormDatabase, error)
OpenSQLiteDatabase creates and open connection to new SQLite3 database.
func (*XormDatabase) CreateAccount ¶
func (db *XormDatabase) CreateAccount(username, password string) error
CreateAccount saves new account to database. Returns new ID and error if any happened.
func (*XormDatabase) DeleteAccounts ¶
func (db *XormDatabase) DeleteAccounts(usernames ...string) error
DeleteAccounts removes all record with matching usernames
func (*XormDatabase) DeleteBookmarks ¶
func (db *XormDatabase) DeleteBookmarks(ids ...int) error
DeleteBookmarks removes all record with matching ids from database.
func (*XormDatabase) GetAccount ¶
func (db *XormDatabase) GetAccount(username string) (model.Account, error)
GetAccount fetch account with matching username
func (*XormDatabase) GetAccounts ¶
func (db *XormDatabase) GetAccounts(keyword string) ([]model.Account, error)
GetAccounts fetch list of accounts with matching keyword
func (*XormDatabase) GetBookmarkID ¶
func (db *XormDatabase) GetBookmarkID(url string) int
GetBookmarkID fetchs bookmark ID based by its url
func (*XormDatabase) GetBookmarks ¶
GetBookmarks fetch list of bookmarks based on submitted ids.
func (*XormDatabase) GetTags ¶
func (db *XormDatabase) GetTags() ([]model.Tag, error)
GetTags fetch list of tags and their frequency
func (*XormDatabase) InsertBookmark ¶
func (db *XormDatabase) InsertBookmark(bookmark *model.Bookmark) error
InsertBookmark inserts new bookmark to database. Returns new ID and error if any happened.
func (*XormDatabase) SearchBookmarks ¶
func (db *XormDatabase) SearchBookmarks(orderLatest bool, keyword string, tags ...string) ([]model.Bookmark, error)
SearchBookmarks search bookmarks by the keyword or tags.
func (*XormDatabase) UpdateBookmarks ¶
func (db *XormDatabase) UpdateBookmarks(bookmarks ...model.Bookmark) (result []model.Bookmark, err error)
UpdateBookmarks updates the saved bookmark in database.