Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionDAO ¶ added in v0.2.0
type CollectionDAO struct {
// contains filtered or unexported fields
}
CollectionDAO persists collections (e.g. tags) in the SQLite database.
func NewCollectionDAO ¶ added in v0.2.0
func NewCollectionDAO(tx Transaction, logger util.Logger) *CollectionDAO
NewCollectionDAO creates a new instance of a DAO working on the given database transaction.
func (*CollectionDAO) Associate ¶ added in v0.2.0
func (d *CollectionDAO) Associate(noteId core.NoteId, collectionId core.CollectionId) (core.NoteCollectionId, error)
Associate creates a new association between a note and a collection, if it does not already exist.
func (*CollectionDAO) FindOrCreate ¶ added in v0.2.0
func (d *CollectionDAO) FindOrCreate(kind note.CollectionKind, name string) (core.CollectionId, error)
FindOrCreate returns the ID of the collection with given kind and name. Creates the collection if it does not already exist.
func (*CollectionDAO) RemoveAssociations ¶ added in v0.2.0
func (d *CollectionDAO) RemoveAssociations(noteId core.NoteId) error
RemoveAssociations deletes all associations with the given note.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB holds the connections to a SQLite database.
func OpenInMemory ¶
OpenInMemory creates a new in-memory DB instance.
func (*DB) WithTransaction ¶
WithTransaction creates a new transaction and handles rollback/commit based on the error object returned by the TxFn closure.
type LazyStmt ¶
type LazyStmt struct {
// contains filtered or unexported fields
}
LazyStmt is a wrapper around a sql.Stmt which will be evaluated on first use.
func NewLazyStmt ¶
NewLazyStmt creates a new lazy statement bound to the given transaction.
type NoteDAO ¶
type NoteDAO struct {
// contains filtered or unexported fields
}
NoteDAO persists notes in the SQLite database. It implements the core port note.Finder.
func NewNoteDAO ¶
func NewNoteDAO(tx Transaction, logger util.Logger) *NoteDAO
NewNoteDAO creates a new instance of a DAO working on the given database transaction.
type NoteIndexer ¶ added in v0.2.0
type NoteIndexer struct {
// contains filtered or unexported fields
}
NoteIndexer persists note indexing results in the SQLite database. It implements the core port note.Indexer and acts as a facade to the DAOs.
func NewNoteIndexer ¶ added in v0.2.0
func NewNoteIndexer(notes *NoteDAO, collections *CollectionDAO, logger util.Logger) *NoteIndexer
func (*NoteIndexer) Indexed ¶ added in v0.2.0
func (i *NoteIndexer) Indexed() (<-chan paths.Metadata, error)
Indexed returns the list of indexed note file metadata.
func (*NoteIndexer) Remove ¶ added in v0.2.0
func (i *NoteIndexer) Remove(path string) error
Remove deletes a note from the index.
type Transaction ¶
type Transaction interface { Exec(query string, args ...interface{}) (sql.Result, error) ExecStmts(stmts []string) error Prepare(query string) (*sql.Stmt, error) PrepareLazy(query string) *LazyStmt Query(query string, args ...interface{}) (*sql.Rows, error) QueryRow(query string, args ...interface{}) *sql.Row }
Transaction is an interface that models the standard transaction in database/sql.
To ensure TxFn funcs cannot commit or rollback a transaction (which is handled by `WithTransaction`), those methods are not included here.
type TxFn ¶
type TxFn func(tx Transaction) error
A Txfn is a function that will be called with an initialized Transaction object that can be used for executing statements and queries against a database.