sqlite

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Family

type Family struct {
	Subject string
	Family  string
	Valid   bool
}

type InsertFamilyParams

type InsertFamilyParams struct {
	Subject string
	Family  string
	Valid   bool
}

type InsertSecretParams

type InsertSecretParams struct {
	Subject string
	Secret  string
}

type InsertSubjectParams

type InsertSubjectParams struct {
	Username string
	Subject  string
}

type InsertUserParams

type InsertUserParams struct {
	Username string
	Password string
}

type Querier

type Querier interface {
	//InsertFamily
	//
	//  INSERT OR REPLACE INTO families (subject, family, valid) VALUES (?, ?, ?)
	InsertFamily(ctx context.Context, arg InsertFamilyParams) error
	//InsertSecret
	//
	//  INSERT OR REPLACE INTO secrets (subject, secret) VALUES (?, ?)
	InsertSecret(ctx context.Context, arg InsertSecretParams) error
	//InsertSubject
	//
	//  INSERT INTO subjects (username, subject) VALUES (?, ?)
	InsertSubject(ctx context.Context, arg InsertSubjectParams) error
	//InsertUser
	//
	//  INSERT INTO users (username, password) VALUES (?, ?)
	InsertUser(ctx context.Context, arg InsertUserParams) error
	//InvalidateUser
	//
	//  UPDATE families SET valid = FALSE WHERE subject = ?
	InvalidateUser(ctx context.Context, subject string) error
	//SelectFamily
	//
	//  SELECT valid FROM families WHERE subject = ? AND family = ?
	SelectFamily(ctx context.Context, arg SelectFamilyParams) (bool, error)
	//SelectPasswordByUsername
	//
	//  SELECT password FROM users WHERE username = ?
	SelectPasswordByUsername(ctx context.Context, username string) (string, error)
	//SelectSecret
	//
	//  SELECT secret FROM secrets WHERE subject = ?
	SelectSecret(ctx context.Context, subject string) (string, error)
	//SelectSubjectByUsername
	//
	//  SELECT subject FROM subjects WHERE username = ?
	SelectSubjectByUsername(ctx context.Context, username string) (string, error)
}

type Queries

type Queries struct {
	// contains filtered or unexported fields
}

func New

func New(db DBTX) *Queries

func (*Queries) InsertFamily

func (q *Queries) InsertFamily(ctx context.Context, arg InsertFamilyParams) error

InsertFamily

INSERT OR REPLACE INTO families (subject, family, valid) VALUES (?, ?, ?)

func (*Queries) InsertSecret

func (q *Queries) InsertSecret(ctx context.Context, arg InsertSecretParams) error

InsertSecret

INSERT OR REPLACE INTO secrets (subject, secret) VALUES (?, ?)

func (*Queries) InsertSubject

func (q *Queries) InsertSubject(ctx context.Context, arg InsertSubjectParams) error

InsertSubject

INSERT INTO subjects (username, subject) VALUES (?, ?)

func (*Queries) InsertUser

func (q *Queries) InsertUser(ctx context.Context, arg InsertUserParams) error

InsertUser

INSERT INTO users (username, password) VALUES (?, ?)

func (*Queries) InvalidateUser

func (q *Queries) InvalidateUser(ctx context.Context, subject string) error

InvalidateUser

UPDATE families SET valid = FALSE WHERE subject = ?

func (*Queries) SelectFamily

func (q *Queries) SelectFamily(ctx context.Context, arg SelectFamilyParams) (bool, error)

SelectFamily

SELECT valid FROM families WHERE subject = ? AND family = ?

func (*Queries) SelectPasswordByUsername

func (q *Queries) SelectPasswordByUsername(ctx context.Context, username string) (string, error)

SelectPasswordByUsername

SELECT password FROM users WHERE username = ?

func (*Queries) SelectSecret

func (q *Queries) SelectSecret(ctx context.Context, subject string) (string, error)

SelectSecret

SELECT secret FROM secrets WHERE subject = ?

func (*Queries) SelectSubjectByUsername

func (q *Queries) SelectSubjectByUsername(ctx context.Context, username string) (string, error)

SelectSubjectByUsername

SELECT subject FROM subjects WHERE username = ?

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type SQLiteDB

type SQLiteDB struct {
	// contains filtered or unexported fields
}

func NewSQLiteDB

func NewSQLiteDB(dbPath string) (*SQLiteDB, error)

func (*SQLiteDB) Close

func (s *SQLiteDB) Close() error

func (*SQLiteDB) InsertFamily

func (s *SQLiteDB) InsertFamily(userId, family string, value bool) error

func (*SQLiteDB) InsertSecret

func (s *SQLiteDB) InsertSecret(userId, secret string) error

func (*SQLiteDB) InsertSubject

func (s *SQLiteDB) InsertSubject(username string, subject string) error

func (*SQLiteDB) InsertUser

func (s *SQLiteDB) InsertUser(username string, password string) error

func (*SQLiteDB) InvalidateUser

func (s *SQLiteDB) InvalidateUser(userId string) error

func (*SQLiteDB) NewUserId

func (s *SQLiteDB) NewUserId() (string, error)

NewUserId generates a new UUID v4 (same implementation as valkey)

func (*SQLiteDB) SelectFamily

func (s *SQLiteDB) SelectFamily(userId, family string) bool

func (*SQLiteDB) SelectPasswordByUsername

func (s *SQLiteDB) SelectPasswordByUsername(username string) (string, error)

func (*SQLiteDB) SelectSecret

func (s *SQLiteDB) SelectSecret(userId string) (string, error)

func (*SQLiteDB) SelectSubjectByUsername

func (s *SQLiteDB) SelectSubjectByUsername(username string) (string, error)

type Secret

type Secret struct {
	Subject string
	Secret  string
}

type SelectFamilyParams

type SelectFamilyParams struct {
	Subject string
	Family  string
}

type Subject

type Subject struct {
	Username string
	Subject  string
}

type User

type User struct {
	Username string
	Password string
}

Jump to

Keyboard shortcuts

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