Documentation ¶
Index ¶
- type DB
- type GetAccountsOptions
- type GetBookmarksOptions
- type MySQLDatabase
- func (db *MySQLDatabase) CreateTags(ctx context.Context, tags ...model.Tag) error
- func (db *MySQLDatabase) DeleteAccounts(ctx context.Context, usernames ...string) error
- func (db *MySQLDatabase) DeleteBookmarks(ctx context.Context, ids ...int) (err error)
- func (db *MySQLDatabase) GetAccount(ctx context.Context, username string) (model.Account, bool, error)
- func (db *MySQLDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
- func (db *MySQLDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
- func (db *MySQLDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
- func (db *MySQLDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
- func (db *MySQLDatabase) GetTags(ctx context.Context) ([]model.Tag, error)
- func (db *MySQLDatabase) Migrate() error
- func (db *MySQLDatabase) RenameTag(ctx context.Context, id int, newName string) error
- func (db *MySQLDatabase) SaveAccount(ctx context.Context, account model.Account) (err error)
- func (db *MySQLDatabase) SaveAccountSettings(ctx context.Context, account model.Account) (err error)
- func (db *MySQLDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) ([]model.BookmarkDTO, error)
- type OrderMethod
- type PGDatabase
- func (db *PGDatabase) CreateTags(ctx context.Context, tags ...model.Tag) error
- func (db *PGDatabase) DeleteAccounts(ctx context.Context, usernames ...string) (err error)
- func (db *PGDatabase) DeleteBookmarks(ctx context.Context, ids ...int) (err error)
- func (db *PGDatabase) GetAccount(ctx context.Context, username string) (model.Account, bool, error)
- func (db *PGDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
- func (db *PGDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
- func (db *PGDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
- func (db *PGDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
- func (db *PGDatabase) GetTags(ctx context.Context) ([]model.Tag, error)
- func (db *PGDatabase) Migrate() error
- func (db *PGDatabase) RenameTag(ctx context.Context, id int, newName string) error
- func (db *PGDatabase) SaveAccount(ctx context.Context, account model.Account) (err error)
- func (db *PGDatabase) SaveAccountSettings(ctx context.Context, account model.Account) (err error)
- func (db *PGDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) (result []model.BookmarkDTO, err error)
- type SQLiteDatabase
- func (db *SQLiteDatabase) CreateTags(ctx context.Context, tags ...model.Tag) error
- func (db *SQLiteDatabase) DeleteAccounts(ctx context.Context, usernames ...string) error
- func (db *SQLiteDatabase) DeleteBookmarks(ctx context.Context, ids ...int) error
- func (db *SQLiteDatabase) GetAccount(ctx context.Context, username string) (model.Account, bool, error)
- func (db *SQLiteDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
- func (db *SQLiteDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
- func (db *SQLiteDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
- func (db *SQLiteDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
- func (db *SQLiteDatabase) GetTags(ctx context.Context) ([]model.Tag, error)
- func (db *SQLiteDatabase) Migrate() error
- func (db *SQLiteDatabase) RenameTag(ctx context.Context, id int, newName string) error
- func (db *SQLiteDatabase) SaveAccount(ctx context.Context, account model.Account) error
- func (db *SQLiteDatabase) SaveAccountSettings(ctx context.Context, account model.Account) error
- func (db *SQLiteDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) ([]model.BookmarkDTO, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB interface { // Migrate runs migrations for this database Migrate() error // SaveBookmarks saves bookmarks data to database. SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) ([]model.BookmarkDTO, error) // GetBookmarks fetch list of bookmarks based on submitted options. GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error) // GetBookmarksCount get count of bookmarks in database. GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error) // DeleteBookmarks removes all record with matching ids from database. DeleteBookmarks(ctx context.Context, ids ...int) error // GetBookmark fetches bookmark based on its ID or URL. GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error) // SaveAccount saves new account in database SaveAccount(ctx context.Context, a model.Account) error // SaveAccountSettings saves settings for specific user in database SaveAccountSettings(ctx context.Context, a model.Account) error // GetAccounts fetch list of account (without its password) with matching keyword. GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error) // GetAccount fetch account with matching username. GetAccount(ctx context.Context, username string) (model.Account, bool, error) // DeleteAccounts removes all record with matching usernames DeleteAccounts(ctx context.Context, usernames ...string) error // CreateTags creates new tags in database. CreateTags(ctx context.Context, tags ...model.Tag) error // GetTags fetch list of tags and its frequency from database. GetTags(ctx context.Context) ([]model.Tag, error) // RenameTag change the name of a tag. RenameTag(ctx context.Context, id int, newName string) error }
DB is interface for accessing and manipulating data in database.
type GetAccountsOptions ¶
GetAccountsOptions is options for fetching accounts from database.
type GetBookmarksOptions ¶
type GetBookmarksOptions struct { IDs []int Tags []string ExcludedTags []string Keyword string WithContent bool OrderMethod OrderMethod Limit int Offset int }
GetBookmarksOptions is options for fetching bookmarks from database.
type MySQLDatabase ¶
type MySQLDatabase struct {
// contains filtered or unexported fields
}
MySQLDatabase is implementation of Database interface for connecting to MySQL or MariaDB database.
func OpenMySQLDatabase ¶
func OpenMySQLDatabase(ctx context.Context, connString string) (mysqlDB *MySQLDatabase, err error)
OpenMySQLDatabase creates and opens connection to a MySQL Database.
func (*MySQLDatabase) CreateTags ¶ added in v1.6.0
CreateTags creates new tags from submitted objects.
func (*MySQLDatabase) DeleteAccounts ¶
func (db *MySQLDatabase) DeleteAccounts(ctx context.Context, usernames ...string) error
DeleteAccounts removes all record with matching usernames.
func (*MySQLDatabase) DeleteBookmarks ¶
func (db *MySQLDatabase) DeleteBookmarks(ctx context.Context, ids ...int) (err error)
DeleteBookmarks removes all record with matching ids from database.
func (*MySQLDatabase) GetAccount ¶
func (db *MySQLDatabase) GetAccount(ctx context.Context, username string) (model.Account, bool, error)
GetAccount fetch account with matching username. Returns the account and boolean whether it's exist or not.
func (*MySQLDatabase) GetAccounts ¶
func (db *MySQLDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
GetAccounts fetch list of account (without its password) based on submitted options.
func (*MySQLDatabase) GetBookmark ¶
func (db *MySQLDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
GetBookmark fetches bookmark based on its ID or URL. Returns the bookmark and boolean whether it's exist or not.
func (*MySQLDatabase) GetBookmarks ¶
func (db *MySQLDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
GetBookmarks fetch list of bookmarks based on submitted options.
func (*MySQLDatabase) GetBookmarksCount ¶
func (db *MySQLDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
GetBookmarksCount fetch count of bookmarks based on submitted options.
func (*MySQLDatabase) Migrate ¶ added in v1.5.3
func (db *MySQLDatabase) Migrate() error
Migrate runs migrations for this database engine
func (*MySQLDatabase) SaveAccount ¶
SaveAccount saves new account to database. Returns error if any happened.
func (*MySQLDatabase) SaveAccountSettings ¶ added in v1.6.0
func (db *MySQLDatabase) SaveAccountSettings(ctx context.Context, account model.Account) (err error)
SaveAccountSettings update settings for specific account in database. Returns error if any happened
func (*MySQLDatabase) SaveBookmarks ¶
func (db *MySQLDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) ([]model.BookmarkDTO, error)
SaveBookmarks saves new or updated bookmarks to database. Returns the saved ID and error message if any happened.
type OrderMethod ¶
type OrderMethod int
OrderMethod is the order method for getting bookmarks
const ( // DefaultOrder is oldest to newest. DefaultOrder OrderMethod = iota // ByLastAdded is from newest addition to the oldest. ByLastAdded // ByLastModified is from latest modified to the oldest. ByLastModified )
type PGDatabase ¶ added in v1.5.1
type PGDatabase struct {
// contains filtered or unexported fields
}
PGDatabase is implementation of Database interface for connecting to PostgreSQL database.
func OpenPGDatabase ¶ added in v1.5.1
func OpenPGDatabase(ctx context.Context, connString string) (pgDB *PGDatabase, err error)
OpenPGDatabase creates and opens connection to a PostgreSQL Database.
func (*PGDatabase) CreateTags ¶ added in v1.6.0
CreateTags creates new tags from submitted objects.
func (*PGDatabase) DeleteAccounts ¶ added in v1.5.1
func (db *PGDatabase) DeleteAccounts(ctx context.Context, usernames ...string) (err error)
DeleteAccounts removes all record with matching usernames.
func (*PGDatabase) DeleteBookmarks ¶ added in v1.5.1
func (db *PGDatabase) DeleteBookmarks(ctx context.Context, ids ...int) (err error)
DeleteBookmarks removes all record with matching ids from database.
func (*PGDatabase) GetAccount ¶ added in v1.5.1
GetAccount fetch account with matching username. Returns the account and boolean whether it's exist or not.
func (*PGDatabase) GetAccounts ¶ added in v1.5.1
func (db *PGDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
GetAccounts fetch list of account (without its password) based on submitted options.
func (*PGDatabase) GetBookmark ¶ added in v1.5.1
func (db *PGDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
GetBookmark fetches bookmark based on its ID or URL. Returns the bookmark and boolean whether it's exist or not.
func (*PGDatabase) GetBookmarks ¶ added in v1.5.1
func (db *PGDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
GetBookmarks fetch list of bookmarks based on submitted options.
func (*PGDatabase) GetBookmarksCount ¶ added in v1.5.1
func (db *PGDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
GetBookmarksCount fetch count of bookmarks based on submitted options.
func (*PGDatabase) Migrate ¶ added in v1.5.3
func (db *PGDatabase) Migrate() error
Migrate runs migrations for this database engine
func (*PGDatabase) SaveAccount ¶ added in v1.5.1
SaveAccount saves new account to database. Returns error if any happened.
func (*PGDatabase) SaveAccountSettings ¶ added in v1.6.0
SaveAccountSettings update settings for specific account in database. Returns error if any happened
func (*PGDatabase) SaveBookmarks ¶ added in v1.5.1
func (db *PGDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) (result []model.BookmarkDTO, err error)
SaveBookmarks saves new or updated bookmarks to database. Returns the saved ID and error message if any happened.
type SQLiteDatabase ¶
type SQLiteDatabase struct {
// contains filtered or unexported fields
}
SQLiteDatabase is implementation of Database interface for connecting to SQLite3 database.
func OpenSQLiteDatabase ¶
func OpenSQLiteDatabase(ctx context.Context, databasePath string) (sqliteDB *SQLiteDatabase, err error)
OpenSQLiteDatabase creates and open connection to new SQLite3 database.
func (*SQLiteDatabase) CreateTags ¶ added in v1.6.0
CreateTags creates new tags from submitted objects.
func (*SQLiteDatabase) DeleteAccounts ¶
func (db *SQLiteDatabase) DeleteAccounts(ctx context.Context, usernames ...string) error
DeleteAccounts removes all record with matching usernames.
func (*SQLiteDatabase) DeleteBookmarks ¶
func (db *SQLiteDatabase) DeleteBookmarks(ctx context.Context, ids ...int) error
DeleteBookmarks removes all record with matching ids from database.
func (*SQLiteDatabase) GetAccount ¶
func (db *SQLiteDatabase) GetAccount(ctx context.Context, username string) (model.Account, bool, error)
GetAccount fetch account with matching username. Returns the account and boolean whether it's exist or not.
func (*SQLiteDatabase) GetAccounts ¶
func (db *SQLiteDatabase) GetAccounts(ctx context.Context, opts GetAccountsOptions) ([]model.Account, error)
GetAccounts fetch list of account (without its password) based on submitted options.
func (*SQLiteDatabase) GetBookmark ¶
func (db *SQLiteDatabase) GetBookmark(ctx context.Context, id int, url string) (model.BookmarkDTO, bool, error)
GetBookmark fetches bookmark based on its ID or URL. Returns the bookmark and boolean whether it's exist or not.
func (*SQLiteDatabase) GetBookmarks ¶
func (db *SQLiteDatabase) GetBookmarks(ctx context.Context, opts GetBookmarksOptions) ([]model.BookmarkDTO, error)
GetBookmarks fetch list of bookmarks based on submitted options.
func (*SQLiteDatabase) GetBookmarksCount ¶
func (db *SQLiteDatabase) GetBookmarksCount(ctx context.Context, opts GetBookmarksOptions) (int, error)
GetBookmarksCount fetch count of bookmarks based on submitted options.
func (*SQLiteDatabase) Migrate ¶ added in v1.5.3
func (db *SQLiteDatabase) Migrate() error
Migrate runs migrations for this database engine
func (*SQLiteDatabase) SaveAccount ¶
SaveAccount saves new account to database. Returns error if any happened.
func (*SQLiteDatabase) SaveAccountSettings ¶ added in v1.6.0
SaveAccountSettings update settings for specific account in database. Returns error if any happened.
func (*SQLiteDatabase) SaveBookmarks ¶
func (db *SQLiteDatabase) SaveBookmarks(ctx context.Context, create bool, bookmarks ...model.BookmarkDTO) ([]model.BookmarkDTO, error)
SaveBookmarks saves new or updated bookmarks to database. Returns the saved ID and error message if any happened.