Documentation ¶
Index ¶
- type Database
- func (d *Database) Connect() error
- func (d *Database) CreateArticle(ctx context.Context, a model.Article) error
- func (d *Database) GetArticle(ctx context.Context, id int, search string) (*model.Article, error)
- func (d *Database) GetTOC(ctx context.Context) ([]model.Article, error)
- func (d *Database) MigrateDown(ctx context.Context) error
- func (d *Database) MigrateUp(ctx context.Context) error
- func (d *Database) SearchArticles(ctx context.Context, search string) ([]model.Article, error)
- type NewDatabaseOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶
func NewDatabase ¶
func NewDatabase(opts NewDatabaseOptions) *Database
NewDatabase with the given options. If no logger is provided, logs are discarded.
func (*Database) CreateArticle ¶
CreateArticle with title and content, ignoring any ID or timestamps.
func (*Database) GetArticle ¶
GetArticle by ID, returning nil if no such ID exists. If search is not empty, highlight the given search query in the title and content.
func (*Database) SearchArticles ¶
SearchArticles with the given search query. Matches in titles are highlighted with the unit separator character ␟. Matches in content return a snippet of the content, also highlighted with the unit separator character ␟. Results are ordered by the internal rank of fts5. See https://www.sqlite.org/fts5.html
Click to show internal directories.
Click to hide internal directories.