Documentation ¶
Index ¶
- type CollectionDAO
- func (d *CollectionDAO) Associate(noteId core.NoteID, collectionId core.CollectionID) (core.NoteCollectionID, error)
- func (d *CollectionDAO) FindAll(kind core.CollectionKind, sorters []core.CollectionSorter) ([]core.Collection, error)
- func (d *CollectionDAO) FindOrCreate(kind core.CollectionKind, name string) (core.CollectionID, error)
- func (d *CollectionDAO) RemoveAssociations(noteId core.NoteID) error
- type DB
- type LazyStmt
- type LinkDAO
- type MetadataDAO
- type NoteDAO
- func (d *NoteDAO) Add(note core.Note) (core.NoteID, error)
- func (d *NoteDAO) Find(opts core.NoteFindOpts) ([]core.ContextualNote, error)
- func (d *NoteDAO) FindIdByHref(href string, allowPartialHref bool) (core.NoteID, error)
- func (d *NoteDAO) FindIdByPath(path string) (core.NoteID, error)
- func (d *NoteDAO) FindIdsByHref(href string, allowPartialHref bool) ([]core.NoteID, error)
- func (d *NoteDAO) FindMinimal(opts core.NoteFindOpts) ([]core.MinimalNote, error)
- func (d *NoteDAO) Indexed() (<-chan paths.Metadata, error)
- func (d *NoteDAO) Remove(path string) error
- func (d *NoteDAO) Update(note core.Note) (core.NoteID, error)
- type NoteIndex
- func (ni *NoteIndex) Add(note core.Note) (id core.NoteID, err error)
- func (ni *NoteIndex) Commit(transaction func(idx core.NoteIndex) error) error
- func (ni *NoteIndex) Find(opts core.NoteFindOpts) (notes []core.ContextualNote, err error)
- func (ni *NoteIndex) FindCollections(kind core.CollectionKind, sorters []core.CollectionSorter) (collections []core.Collection, err error)
- func (ni *NoteIndex) FindLinksBetweenNotes(ids []core.NoteID) (links []core.ResolvedLink, err error)
- func (ni *NoteIndex) FindMinimal(opts core.NoteFindOpts) (notes []core.MinimalNote, err error)
- func (ni *NoteIndex) IndexedPaths() (metadata <-chan paths.Metadata, err error)
- func (ni *NoteIndex) NeedsReindexing() (needsReindexing bool, err error)
- func (ni *NoteIndex) Remove(path string) error
- func (ni *NoteIndex) SetNeedsReindexing(needsReindexing bool) error
- func (ni *NoteIndex) Update(note core.Note) error
- type RowQuerier
- type RowScanner
- type Transaction
- type TxFn
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CollectionDAO ¶
type CollectionDAO struct {
// contains filtered or unexported fields
}
CollectionDAO persists collections (e.g. tags) in the SQLite database.
func NewCollectionDAO ¶
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 ¶
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) FindAll ¶
func (d *CollectionDAO) FindAll(kind core.CollectionKind, sorters []core.CollectionSorter) ([]core.Collection, error)
func (*CollectionDAO) FindOrCreate ¶
func (d *CollectionDAO) FindOrCreate(kind core.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 ¶
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 LinkDAO ¶ added in v0.8.0
type LinkDAO struct {
// contains filtered or unexported fields
}
LinkDAO persists links in the SQLite database.
func NewLinkDAO ¶ added in v0.8.0
func NewLinkDAO(tx Transaction, logger util.Logger) *LinkDAO
NewLinkDAO creates a new instance of a DAO working on the given database transaction.
func (*LinkDAO) Add ¶ added in v0.8.0
func (d *LinkDAO) Add(links []core.ResolvedLink) error
Add inserts all the outbound links of the given note.
func (*LinkDAO) FindBetweenNotes ¶ added in v0.8.0
type MetadataDAO ¶
type MetadataDAO struct {
// contains filtered or unexported fields
}
MetadataDAO persists arbitrary key/value pairs in the SQLite database.
func NewMetadataDAO ¶
func NewMetadataDAO(tx Transaction) *MetadataDAO
NewMetadataDAO creates a new instance of a DAO working on the given database transaction.
type NoteDAO ¶
type NoteDAO struct {
// contains filtered or unexported fields
}
NoteDAO persists notes in the SQLite database.
func NewNoteDAO ¶
func NewNoteDAO(tx Transaction, logger util.Logger) *NoteDAO
NewNoteDAO creates a new instance of a DAO working on the given database transaction.
func (*NoteDAO) Find ¶
func (d *NoteDAO) Find(opts core.NoteFindOpts) ([]core.ContextualNote, error)
Find returns all the notes matching the given criteria.
func (*NoteDAO) FindIdByHref ¶ added in v0.8.0
func (*NoteDAO) FindIdByPath ¶ added in v0.8.0
func (*NoteDAO) FindIdsByHref ¶ added in v0.9.0
func (*NoteDAO) FindMinimal ¶
func (d *NoteDAO) FindMinimal(opts core.NoteFindOpts) ([]core.MinimalNote, error)
type NoteIndex ¶
type NoteIndex struct {
// contains filtered or unexported fields
}
NoteIndex persists note indexing results in the SQLite database. It implements the port core.NoteIndex and acts as a facade to the DAOs.
func (*NoteIndex) Find ¶
func (ni *NoteIndex) Find(opts core.NoteFindOpts) (notes []core.ContextualNote, err error)
Find implements core.NoteIndex.
func (*NoteIndex) FindCollections ¶
func (ni *NoteIndex) FindCollections(kind core.CollectionKind, sorters []core.CollectionSorter) (collections []core.Collection, err error)
FindCollections implements core.NoteIndex.
func (*NoteIndex) FindLinksBetweenNotes ¶ added in v0.8.0
func (ni *NoteIndex) FindLinksBetweenNotes(ids []core.NoteID) (links []core.ResolvedLink, err error)
FindLinksBetweenNotes implements core.NoteIndex.
func (*NoteIndex) FindMinimal ¶
func (ni *NoteIndex) FindMinimal(opts core.NoteFindOpts) (notes []core.MinimalNote, err error)
FindMinimal implements core.NoteIndex.
func (*NoteIndex) IndexedPaths ¶
IndexedPaths implements core.NoteIndex.
func (*NoteIndex) NeedsReindexing ¶
NeedsReindexing implements core.NoteIndex.
func (*NoteIndex) SetNeedsReindexing ¶
SetNeedsReindexing implements core.NoteIndex.
type RowQuerier ¶ added in v0.8.0
type RowScanner ¶
type RowScanner interface {
Scan(dest ...interface{}) error
}
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.