database

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2026 License: GPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddFlashcard

func AddFlashcard(db *sql.DB, front, back string, groups, tags []parser.Filter) (int, error)

TODO: add doc comments TODO: add plugin ext_data to args and to database exec

func DatabasePath

func DatabasePath() string

func GetFlashcardGroups

func GetFlashcardGroups(db *sql.DB, id int) ([]string, error)

func GetFlashcardTags

func GetFlashcardTags(db *sql.DB, id int) ([]string, error)

func Init

func Init(db *sql.DB) error

Init executes creation of any tables for the database if they do not exist

func Open

func Open() (*sql.DB, error)

Open opens sqlite database at path appropriate for user's operating system

func UpdateFlashcardExtDataWithTx

func UpdateFlashcardExtDataWithTx(ctx context.Context, tx *sql.Tx, oldCard Flashcard, newCard Flashcard) error

func UpdateFlashcardLastReviewWithTx

func UpdateFlashcardLastReviewWithTx(ctx context.Context, tx *sql.Tx, oldCard, newCard Flashcard) error

func UpdateFullFlashcard

func UpdateFullFlashcard(ctx context.Context, db *sql.DB, oldCard FullFlashcard, newCard FullFlashcard) error

Types

type Flashcard

type Flashcard struct {
	ID         int    `db:"id"`
	UUID       string `db:"uuid"`
	LastReview int    `db:"last_review"`
	Front      string `db:"front"`
	Back       string `db:"back"`
	CreatedAt  int    `db:"created_at"`
	ExtData    []byte `db:"ext_data"`
}

func GetAllFlashcards

func GetAllFlashcards(db *sql.DB) ([]Flashcard, error)

func GetFlashcards

func GetFlashcards(db *sql.DB, filters parser.SearchFilters) ([]Flashcard, error)

func (Flashcard) Copy

func (c Flashcard) Copy() Flashcard

func (Flashcard) Equals

func (c Flashcard) Equals(other Flashcard) bool

type FullFlashcard

type FullFlashcard struct {
	Flashcard
	Groups []string
	Tags   []string
}

Jump to

Keyboard shortcuts

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