models

package
v0.0.0-...-7f373d5 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2022 License: LGPL-3.0 Imports: 4 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastore

type Datastore interface {
	FlushErrors() error

	SearchBookmarks(string) []*types.Bookmark
	GetBookmark(int) *types.Bookmark
	GetBookmarkTags(int) []*types.Tag
	GetFolderBookmarks(int) types.Bookmarks
	SaveBookmark(*types.Bookmark) int64
	UpdateBookmark(*types.Bookmark)
	DeleteBookmark(*types.Bookmark)

	GetFolder(int) *types.Folder
	GetFolderSubfolders(int) []*types.Folder
	SaveFolder(*types.Folder) int64
	UpdateFolder(*types.Folder)
	DeleteFolder(*types.Folder)

	GetTags() []*types.Tag
	GetStars() []*types.Bookmark
	GetTag(int) *types.Tag
	SaveTag(*types.Tag) int64
}

Datastore is a folders and bookmarks storage interface.

type SQLiteDataStore

type SQLiteDataStore struct {
	*sql.DB
	// contains filtered or unexported fields
}

SQLiteDataStore implements the Datastore interface to store the folders and bookmarks in SQLite3.

func NewDBstore

func NewDBstore(dataSourceName string) (*SQLiteDataStore, error)

NewDBstore returns a database connection to the given dataSourceName ie. a path to the sqlite database file.

func (*SQLiteDataStore) CreateDatabase

func (db *SQLiteDataStore) CreateDatabase()

CreateDatabase creates the database tables.

func (*SQLiteDataStore) DeleteBookmark

func (db *SQLiteDataStore) DeleteBookmark(b *types.Bookmark)

DeleteBookmark delete the given Bookmark from the db

func (*SQLiteDataStore) DeleteFolder

func (db *SQLiteDataStore) DeleteFolder(f *types.Folder)

DeleteFolder delete the given Folder from the db.

func (*SQLiteDataStore) FlushErrors

func (db *SQLiteDataStore) FlushErrors() error

FlushErrors returns the last DB errors and flushes it.

func (*SQLiteDataStore) GetBookmark

func (db *SQLiteDataStore) GetBookmark(id int) *types.Bookmark

GetBookmark returns a Bookmark instance with the given id.

func (*SQLiteDataStore) GetBookmarkTags

func (db *SQLiteDataStore) GetBookmarkTags(id int) []*types.Tag

GetBookmarkTags returns the tags of the bookmark

func (*SQLiteDataStore) GetFolder

func (db *SQLiteDataStore) GetFolder(id int) *types.Folder

GetFolder returns a Folder instance with the given id.

func (*SQLiteDataStore) GetFolderBookmarks

func (db *SQLiteDataStore) GetFolderBookmarks(id int) types.Bookmarks

GetFolderBookmarks returns the bookmarks of the given folder id.

func (*SQLiteDataStore) GetFolderSubfolders

func (db *SQLiteDataStore) GetFolderSubfolders(id int) []*types.Folder

GetFolderSubfolders returns the children folders as an array of *Folder

func (*SQLiteDataStore) GetStars

func (db *SQLiteDataStore) GetStars() []*types.Bookmark

GetStars returns the starred bookmarks.

func (*SQLiteDataStore) GetTag

func (db *SQLiteDataStore) GetTag(id int) *types.Tag

GetTag returns a Tag instance with the given id.

func (*SQLiteDataStore) GetTags

func (db *SQLiteDataStore) GetTags() []*types.Tag

GetBookmark returns the full tags list

func (*SQLiteDataStore) PopulateDatabase

func (db *SQLiteDataStore) PopulateDatabase()

PopulateDatabase populate the database with sample folders and bookmarks.

func (*SQLiteDataStore) SaveBookmark

func (db *SQLiteDataStore) SaveBookmark(b *types.Bookmark) int64

SaveBookmark saves the new given Bookmark into the db

func (*SQLiteDataStore) SaveFolder

func (db *SQLiteDataStore) SaveFolder(f *types.Folder) int64

SaveFolder saves the given new Folder into the db and returns the folder id. Called only on folder creation or rename so only the Title has to be set.

func (*SQLiteDataStore) SaveTag

func (db *SQLiteDataStore) SaveTag(t *types.Tag) int64

SaveTag saves the new given Tag into the db

func (*SQLiteDataStore) SearchBookmarks

func (db *SQLiteDataStore) SearchBookmarks(s string) []*types.Bookmark

SearchBookmarks returns the bookmarks with the title containing the given string.

func (*SQLiteDataStore) UpdateBookmark

func (db *SQLiteDataStore) UpdateBookmark(b *types.Bookmark)

UpdateBookmark updates the given bookmark.

func (*SQLiteDataStore) UpdateFolder

func (db *SQLiteDataStore) UpdateFolder(f *types.Folder)

UpdateFolder updates the given folder.

Jump to

Keyboard shortcuts

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