services

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package services includes models and services that communicate with the database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearAllKeysHistory

func ClearAllKeysHistory(tx *sql.Tx, prefix string)

func ClearKeyHistory

func ClearKeyHistory(tx *sql.Tx, key string)

func GetValue

func GetValue(tx *sql.Tx, key string) (*string, *time.Time)

func HideKey added in v0.2.0

func HideKey(tx *sql.Tx, key string)

func InsertRawRows added in v0.6.0

func InsertRawRows(tx *sql.Tx, rows []RawRow)

func ListKeys

func ListKeys(tx *sql.Tx, prefix string, matchType MatchType) []string

func LockKey

func LockKey(tx *sql.Tx, key string, password string)

func MigrateInvalidKeys added in v0.6.0

func MigrateInvalidKeys()

MigrateInvalidKeys displays warning when it detects keys with @ in their names this check will always run in app start, it might be deleted in future releases

func MigrateOldDBName added in v0.6.0

func MigrateOldDBName()

MigrateOldDBName migrates old 'kv' db into new 'default' DB this check will always run in app start, it might be deleted in future releases

func MoveKey added in v0.6.0

func MoveKey(tx *sql.Tx, oldKey string, newKey string)

func PruneKey

func PruneKey(tx *sql.Tx, key string)

PruneKey removes all rows with that key from the DB

func RunInTransaction added in v0.1.4

func RunInTransaction(name string, fn func(tx *sql.Tx))

RunInTransaction automatically cleans up DB then runs given function, all inside a transaction.

func SearchKeys added in v0.4.3

func SearchKeys(tx *sql.Tx, part string, matchType MatchType) []string

SearchKeys matches any key containing part as a substring, for use in completions

func SetValue

func SetValue(tx *sql.Tx, key string, value string, expiresAt *time.Time, isLocked bool)

func ShowKey added in v0.2.0

func ShowKey(tx *sql.Tx, key string)

func UnlockKey

func UnlockKey(tx *sql.Tx, key string, password string) error

Types

type KVItem

type KVItem struct {
	Key       string     `json:"key,omitempty" yaml:"key,omitempty"`
	Value     string     `json:"value,omitempty" yaml:"value,omitempty"`
	IsLocked  bool       `json:"isLocked,omitempty" yaml:"is-locked,omitempty"`
	IsHidden  bool       `json:"isHidden,omitempty" yaml:"is-hidden,omitempty"`
	ExpiresAt *time.Time `json:"expiresAt,omitempty" yaml:"expires-at,omitempty"`
	Timestamp time.Time  `json:"timestamp" yaml:"timestamp"`
}

func GetHistoryItem

func GetHistoryItem(tx *sql.Tx, key string, steps int) KVItem

func GetItem

func GetItem(tx *sql.Tx, key string) *KVItem

func ListItems

func ListItems(tx *sql.Tx, prefix string, matchType MatchType) []KVItem

func ListKeyHistory

func ListKeyHistory(tx *sql.Tx, key string) []KVItem

func (KVItem) String

func (item KVItem) String() string

type MatchType

type MatchType int
const (
	MatchAll MatchType = iota
	MatchExisting
	MatchDeleted
)

type RawRow added in v0.6.0

type RawRow map[string]any

func ParseRawRows added in v0.6.0

func ParseRawRows(rows *sql.Rows) []RawRow

func ScanRawRows added in v0.6.0

func ScanRawRows(tx *sql.Tx, key string) []RawRow

Jump to

Keyboard shortcuts

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