sqlite

package
v0.0.0-...-7447204 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDBError      = errors.New("database error")
	ErrNotFoundUser = errors.New("user not found")
)
View Source
var (
	ErrNotFoundSecret = errors.New("secret not found")
)
View Source
var (
	ErrNotFoundShare = errors.New("shared secret not found")
)

Functions

func IsSecretFound

func IsSecretFound(res sql.Result) error

IsSecretFound returns an error if the entity is not found

func IsShareFound

func IsShareFound(res sql.Result) error

IsShareFound returns an error if the entity is not found

func IsUserFound

func IsUserFound(res sql.Result) error

IsUserFound returns an error if the entity is not found

func NewSecretRepository

func NewSecretRepository(db *sql.DB) secret.Repository

NewSecretRepository creates a secret.Repository from the SQL DB `db`

func NewSharedRepository

func NewSharedRepository(db *sql.DB) shared.Repository

NewSharedRepository creates a shared.Repository from the SQL DB `db`

func NewUserRepository

func NewUserRepository(db *sql.DB) user.Repository

NewUserRepository creates a user.Repository from the SQL DB `db`

func Open

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

Open will initialize a SQLite DB based on the `.sql` file in `path`, returning a pointer to a sql.DB and an error

It executes the initial migration, as well.

func ToSQLInt64

func ToSQLInt64[T constraints.Integer](v T) sql.NullInt64

ToSQLInt64 converts the generic integer into a sql.NullInt64

func ToSQLString

func ToSQLString(s string) sql.NullString

ToSQLString converts the input string into a sql.NullString

func ToSQLTime

func ToSQLTime(t time.Time) sql.NullTime

ToSQLTime converts the input time into a sql.NullTime

Types

type Executer

type Executer interface {
	ExecContext(ctx context.Context, query string, args ...interface{}) (sql.Result, error)
}

Executer describes an object that executes a mutation in a SQL database

type Querier

type Querier interface {
	RowQuerier
	RowsQuerier
	Executer
}

Querier encapsulates a RowQuerier, RowsQuerier and Executer implementations

type RowQuerier

type RowQuerier interface {
	QueryRowContext(ctx context.Context, query string, args ...interface{}) *sql.Row
}

RowQuerier describes an object that queries a single row in a SQL database

type RowsQuerier

type RowsQuerier interface {
	QueryContext(ctx context.Context, query string, args ...interface{}) (*sql.Rows, error)
}

RowsQuerier describes an object that queries multiple rows in a SQL database

type Scanner

type Scanner interface {
	Scan(dest ...interface{}) error
}

Scanner describes an object that scans values into destination pointers

Jump to

Keyboard shortcuts

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