database

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database interface {
	// SaveBookmark saves new bookmark to database.
	CreateBookmark(bookmark model.Bookmark) (int64, error)

	// GetBookmarks fetch list of bookmarks based on submitted indices.
	GetBookmarks(withContent bool, indices ...string) ([]model.Bookmark, error)

	// DeleteBookmarks removes all record with matching indices from database.
	DeleteBookmarks(indices ...string) ([]int, []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

	// GetAccounts fetch list of accounts in database
	GetAccounts(keyword string, exact bool) ([]model.Account, error)

	// DeleteAccounts removes all record with matching usernames
	DeleteAccounts(usernames ...string) error
}

Database is interface for manipulating data in database.

type SQLiteDatabase

type SQLiteDatabase struct {
	sqlx.DB
}

SQLiteDatabase is implementation of Database interface for connecting to SQLite3 database.

func OpenSQLiteDatabase

func OpenSQLiteDatabase() (*SQLiteDatabase, error)

OpenSQLiteDatabase creates and open connection to new SQLite3 database.

func (*SQLiteDatabase) CreateAccount

func (db *SQLiteDatabase) CreateAccount(username, password string) (err error)

CreateAccount saves new account to database. Returns new ID and error if any happened.

func (*SQLiteDatabase) CreateBookmark

func (db *SQLiteDatabase) CreateBookmark(bookmark model.Bookmark) (bookmarkID int64, err error)

CreateBookmark saves new bookmark to database. Returns new ID and error if any happened.

func (*SQLiteDatabase) DeleteAccounts

func (db *SQLiteDatabase) DeleteAccounts(usernames ...string) error

DeleteAccounts removes all record with matching usernames

func (*SQLiteDatabase) DeleteBookmarks

func (db *SQLiteDatabase) DeleteBookmarks(indices ...string) (oldIndices, newIndices []int, err error)

DeleteBookmarks removes all record with matching indices from database.

func (*SQLiteDatabase) GetAccounts

func (db *SQLiteDatabase) GetAccounts(keyword string, exact bool) ([]model.Account, error)

GetAccounts fetch list of accounts in database

func (*SQLiteDatabase) GetBookmarks

func (db *SQLiteDatabase) GetBookmarks(withContent bool, indices ...string) ([]model.Bookmark, error)

GetBookmarks fetch list of bookmarks based on submitted indices.

func (*SQLiteDatabase) SearchBookmarks

func (db *SQLiteDatabase) SearchBookmarks(orderLatest bool, keyword string, tags ...string) ([]model.Bookmark, error)

SearchBookmarks search bookmarks by the keyword or tags.

func (*SQLiteDatabase) UpdateBookmarks

func (db *SQLiteDatabase) UpdateBookmarks(bookmarks []model.Bookmark) (result []model.Bookmark, err error)

UpdateBookmarks updates the saved bookmark in database.

Jump to

Keyboard shortcuts

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