sqlite

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrCreateSchema        = Error("create schema")
	ErrDatabaseExists      = Error("database exists")
	ErrDuplicateHash       = Error("duplicate hash")
	ErrDuplicateReportName = Error("duplicate report name")
	ErrForeignKeysDisabled = Error("foreign keys disabled")
	ErrInvalidClanId       = Error("invalid clan id")
	ErrInvalidHash         = Error("invalid hash")
	ErrInvalidPath         = Error("invalid path")
	ErrInvalidMonth        = Error("invalid month")
	ErrInvalidUnit         = Error("invalid unit")
	ErrInvalidYear         = Error("invalid year")
	ErrNotDirectory        = Error("not a directory")
	ErrNotFound            = Error("not found")
	ErrPragmaReturnedNil   = Error("pragma returned nil")
)

Variables

This section is empty.

Functions

func Create

func Create(path string, ctx context.Context) error

Create creates a new store. Returns an error if the database file already exists. The caller must delete the database file if they want to start fresh.

Types

type CreateNewReportParams

type CreateNewReportParams struct {
	Clan  int64
	Year  int64
	Month int64
	Unit  string
	Hash  string
	Lines string
}

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 DeleteReportByHashParams

type DeleteReportByHashParams struct {
	Clan int64
	Hash string
}

type DeleteReportByNameParams

type DeleteReportByNameParams struct {
	Clan  int64
	Year  int64
	Month int64
	Unit  string
}

type Error

type Error string

func (Error) Error

func (e Error) Error() string

type GetReportByHashParams

type GetReportByHashParams struct {
	Clan int64
	Hash string
}

type GetReportByHashRow

type GetReportByHashRow struct {
	ID    int64
	Clan  int64
	Year  int64
	Month int64
	Unit  string
}

type GetReportsByTurnParams

type GetReportsByTurnParams struct {
	Clan  int64
	Year  int64
	Month int64
}

type GetReportsByTurnRow

type GetReportsByTurnRow struct {
	ID    int64
	Clan  int64
	Year  int64
	Month int64
	Unit  string
	Hash  string
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateNewReport

func (q *Queries) CreateNewReport(ctx context.Context, arg CreateNewReportParams) (int64, error)
Copyright (c) 2024 Michael D Henderson. All rights reserved.

-------------------------------------------------------------------------- CreateNewReport creates a new report.

func (*Queries) DeleteReportByHash

func (q *Queries) DeleteReportByHash(ctx context.Context, arg DeleteReportByHashParams) error

-------------------------------------------------------------------------- DeleteReportByHash deletes a report by its hash value.

func (*Queries) DeleteReportByName

func (q *Queries) DeleteReportByName(ctx context.Context, arg DeleteReportByNameParams) error

-------------------------------------------------------------------------- DeleteReportByName returns a report by its name (year, month and unit).

func (*Queries) GetReportByHash

func (q *Queries) GetReportByHash(ctx context.Context, arg GetReportByHashParams) (GetReportByHashRow, error)

-------------------------------------------------------------------------- GetReportByHash returns a report by its hash value.

func (*Queries) GetReportsByTurn

func (q *Queries) GetReportsByTurn(ctx context.Context, arg GetReportsByTurnParams) ([]GetReportsByTurnRow, error)

-------------------------------------------------------------------------- GetReportsByTurn returns a report by its turn number (year and month).

func (*Queries) WithTx

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

type Report

type Report struct {
	ID      int64
	Clan    int64
	Year    int64
	Month   int64
	Unit    string
	Hash    string
	Lines   string
	Created int64
}

type Report_t

type Report_t struct {
	ID    int
	Clan  int
	Year  int
	Month int
	Unit  string
	Hash  string
	Lines string
}

type Store

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

func Open

func Open(path string, ctx context.Context) (*Store, error)

Open opens an existing store. Returns an error if the database file is not a valid file. Caller must call Close() when done.

func (*Store) Close

func (s *Store) Close() error

func (*Store) CreateNewReport

func (s *Store) CreateNewReport(clan, year, month int, unit, hash string, lines []byte) (int, error)

CreateNewReport creates a new report. Returns the id of the new report. Accepts empty input for lines.

func (*Store) Delete

func (s *Store) Delete(stmt string) (sql.Result, error)

func (*Store) DeleteReportByHash

func (s *Store) DeleteReportByHash(clan int, hash string) error

DeleteReportByHash deletes a report by its hash. Returns nil if no report is found.

func (*Store) DeleteReportByName

func (s *Store) DeleteReportByName(clan, year, month int, unit string) error

DeleteReportByName deletes a report by its name (year, month and unit). Returns nil if no report is found.

func (*Store) GetReportByHash

func (s *Store) GetReportByHash(clan int, hash string) (*Report_t, error)

GetReportByHash returns a report by its hash. If no report is found, nil is return with no error.

func (*Store) GetReportsByTurn

func (s *Store) GetReportsByTurn(clan, year, month int) ([]*Report_t, error)

GetReportsByTurn returns a list of reports for the requested clan, year, and month. If no reports are found, an empty list is returned.

func (*Store) Update

func (s *Store) Update(stmt string) (sql.Result, error)

Jump to

Keyboard shortcuts

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