sql

package
v0.0.0-...-5f18729 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2023 License: MIT Imports: 13 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 struct {
	DB *sqlx.DB
	// contains filtered or unexported fields
}

func NewDatabase

func NewDatabase(opts NewDatabaseOptions) *Database

NewDatabase with the given options. If no logger is provided, logs are discarded.

func (*Database) Connect

func (d *Database) Connect() error

func (*Database) CreateArticle

func (d *Database) CreateArticle(ctx context.Context, a model.Article) error

CreateArticle with title and content, ignoring any ID or timestamps.

func (*Database) GetArticle

func (d *Database) GetArticle(ctx context.Context, id int, search string) (*model.Article, error)

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) GetTOC

func (d *Database) GetTOC(ctx context.Context) ([]model.Article, error)

GetTOC of all articles with no content.

func (*Database) MigrateDown

func (d *Database) MigrateDown(ctx context.Context) error

func (*Database) MigrateUp

func (d *Database) MigrateUp(ctx context.Context) error

func (*Database) SearchArticles

func (d *Database) SearchArticles(ctx context.Context, search string) ([]model.Article, error)

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

type NewDatabaseOptions

type NewDatabaseOptions struct {
	URL                   string
	MaxOpenConnections    int
	MaxIdleConnections    int
	ConnectionMaxLifetime time.Duration
	ConnectionMaxIdleTime time.Duration
	Log                   *log.Logger
}

Jump to

Keyboard shortcuts

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