db

package
v0.0.0-...-0c09125 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const MaxMigrationVersion = 11

MaxMigrationVersion is the latest migration version (11 = FTS5 search)

View Source
const MaxMigrationVersionWithoutFTS5 = 10

MaxMigrationVersionWithoutFTS5 is the max version when FTS5 is unavailable

Variables

View Source
var (
	ErrNotFound error = errors.New("record not found")
	ErrInsert   error = errors.New("record insertion failure")
	ErrDelete   error = errors.New("error deleting record")
)

Functions

func Close

func Close() error

func DeleleOneCallout

func DeleleOneCallout(ctx context.Context, c *Callout) error

func DeleteAbraxas

func DeleteAbraxas(ctx context.Context, a *Abraxas) error
func DeleteLink(ctx context.Context, l *Link) error

func DeleteMedia

func DeleteMedia(ctx context.Context, m *Media) error

func Drop

func Drop() error

func ExportDB

func ExportDB() (ret map[string]*bytes.Buffer, err error)

func ExportDBToFiles

func ExportDBToFiles(filepath string) ([]string, error)

func ExportTable

func ExportTable(table string) (*bytes.Buffer, error)

func ExportTableToFile

func ExportTableToFile(filename, table string) error

func InsertAbraxas

func InsertAbraxas(ctx context.Context, a *Abraxas) error

func InsertAlias

func InsertAlias(ctx context.Context, alias *Alias) error

func InsertCallout

func InsertCallout(ctx context.Context, c *Callout) error

func InsertChannelStats

func InsertChannelStats(ctx context.Context, c *ChannelStats) error

func InsertGroup

func InsertGroup(ctx context.Context, gid int64, title string) error
func InsertLink(ctx context.Context, l *Link) error

func InsertMedia

func InsertMedia(ctx context.Context, m *Media) error

func InsertStatistics

func InsertStatistics(ctx context.Context, val, kind int64) error

func InsertStatisticsKind

func InsertStatisticsKind(ctx context.Context, k *StatisticsKind) (int64, error)

func Migrate

func Migrate() error

func MigrateDown

func MigrateDown() error

func MigrateTo

func MigrateTo(version uint) error

func Open

func Open(filename string) error

func SearchRandomMedia

func SearchRandomMedia(ctx context.Context, m *Media, term string) error

func SelectAbraxoidesAbraxas

func SelectAbraxoidesAbraxas(ctx context.Context, gid string) ([]string, error)

func SelectAbraxoidesAbraxasKind

func SelectAbraxoidesAbraxasKind(ctx context.Context, gid string) ([][]string, error)

func SelectAlias

func SelectAlias(ctx context.Context, alias *Alias) error

func SelectAllCallouts

func SelectAllCallouts(ctx context.Context, gid string) ([]string, error)

func SelectLinkByURL

func SelectLinkByURL(ctx context.Context, l *Link) error

func SelectOneAbraxasByAbraxas

func SelectOneAbraxasByAbraxas(ctx context.Context, a *Abraxas) error

func SelectOneCallout

func SelectOneCallout(ctx context.Context, c *Callout) error

func SelectOneGroup

func SelectOneGroup(ctx context.Context, g *Group) error

func SelectOneMediaByData

func SelectOneMediaByData(ctx context.Context, m *Media) error

func SelectOneMediaByRowID

func SelectOneMediaByRowID(ctx context.Context, m *Media) error

func SelectRandomMedia

func SelectRandomMedia(ctx context.Context, m *Media) error

func SelectRandomMediaKind

func SelectRandomMediaKind(ctx context.Context, m *Media) error

func UpdateMediaScoreByRowID

func UpdateMediaScoreByRowID(ctx context.Context, m *Media) error

Types

type Abraxas

type Abraxas struct {
	GID     int64  `db:"gid"`
	Abraxas string `db:"abraxas"`
	Kind    string `db:"kind"`
}

func SelectAbraxoides

func SelectAbraxoides(ctx context.Context, gid string) ([]Abraxas, error)

func (*Abraxas) Clone

func (a *Abraxas) Clone() *Abraxas

type Alias

type Alias struct {
	Name   string `db:"name"`
	Target string `db:"target"`
}

func SelectAllAliases

func SelectAllAliases(ctx context.Context) ([]Alias, error)

type Callout

type Callout struct {
	GID     int64  `db:"gid"`
	Callout string `db:"callout"`
	Text    string `db:"text"`
}

func (*Callout) Clone

func (c *Callout) Clone() *Callout

type ChannelStats

type ChannelStats struct {
	GID    int64  `db:"gid"`
	UID    string `db:"uid"`
	Points int64  `db:"points"`
}

func SelectChannelStats

func SelectChannelStats(ctx context.Context, channel int64) ([]ChannelStats, error)

func SelectChannelStatsUser

func SelectChannelStatsUser(ctx context.Context, channel int64, user string) (*ChannelStats, error)

type ChannelStatsStats

type ChannelStatsStats struct {
	GID   int64 `db:"gid"`
	Min   int   `db:"min"`
	Max   int   `db:"max"`
	Sum   int   `db:"sum"`
	Avg   int   `db:"avg"`
	Count int   `db:"count"`
}

func SelectChannelStatsStats

func SelectChannelStatsStats(ctx context.Context, gid int64) (*ChannelStatsStats, error)

type Group

type Group struct {
	GID   int64  `db:"gid"`
	Title string `db:"title"`
}

func SelectAllGroups

func SelectAllGroups(ctx context.Context) ([]*Group, error)

func (*Group) Clone

func (g *Group) Clone() *Group
type Link struct {
	GID  int64  `db:"gid"`
	URL  string `db:"url"`
	Text string `db:"text"`
}
func SearchLinks(ctx context.Context, gid, term string) (links []*Link, err error)

func (*Link) Clone

func (l *Link) Clone() *Link

type Media

type Media struct {
	RowID       int64     // NOTE: needed by callback queries
	GID         int64     `db:"gid"`
	Data        string    `db:"data"`
	Kind        string    `db:"kind"`
	Description string    `db:"description"`
	Score       int       `db:"score"`
	CreatedAt   time.Time `db:"created_at"`
}

func SearchMedia

func SearchMedia(ctx context.Context, gid int64, term string, offset int) ([]Media, error)

func SelectAllMedia

func SelectAllMedia(ctx context.Context) ([]Media, error)

func SelectAllMediaGroup

func SelectAllMediaGroup(ctx context.Context, gid string) ([]Media, error)

func SelectMediaBottom

func SelectMediaBottom(ctx context.Context, gid int64, top int) ([]Media, error)

func SelectMediaTop

func SelectMediaTop(ctx context.Context, gid int64, top int) ([]Media, error)

func (*Media) Clone

func (m *Media) Clone() *Media

type MediaFts

type MediaFts struct {
	RowID       int64
	Description string `db:"description"`
	GID         int64  `db:"gid"`
}

type Statistics

type Statistics struct {
	KindID int64
	Value  int64
	Date   time.Time
}

type StatisticsJoin

type StatisticsJoin struct {
	Name  string
	Value int64
	Date  time.Time
}

func SelectStatisticsByDateRange

func SelectStatisticsByDateRange(ctx context.Context, timeFrom, timeTo time.Time) ([]*StatisticsJoin, error)

func SelectStatisticsLatest

func SelectStatisticsLatest(ctx context.Context) ([]*StatisticsJoin, error)

type StatisticsKind

type StatisticsKind struct {
	KindID   int64
	Name     string
	Trigger  string
	IsRegexp bool
}

func SelectStatisticKinds

func SelectStatisticKinds(ctx context.Context) ([]*StatisticsKind, error)

Jump to

Keyboard shortcuts

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