db

package
v0.0.0-...-a915469 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TypePostgres holder for postgres database.
	TypePostgres = "POSTGRES"
)

Variables

This section is empty.

Functions

func NewErrAlreadyExists

func NewErrAlreadyExists(msg string) error

NewErrAlreadyExists wraps a message in an AlreadyExistsError object.

Types

type AcceptedTermsURL

type AcceptedTermsURL interface {
	CreateAcceptedTermsURL(ctx context.Context, acceptedTermsURLs ...*models.AcceptedTermsURL) Error
	ReadAcceptedTermsURLForAccount(ctx context.Context, accountID int64) ([]*models.AcceptedTermsURL, Error)
}

type Account

type Account interface {
	CreateAccount(ctx context.Context, account *models.Account) Error
	// ReadAccountByToken(ctx context.Context, token string) (*models.Account, Error)
	ReadAccountByUserID(ctx context.Context, userID string) (*models.Account, Error)
	UpdateAccount(ctx context.Context, account *models.Account) Error
}

type AlreadyExistsError

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

AlreadyExistsError is returned when a caller tries to insert a database entry that already exists in the db.

func (*AlreadyExistsError) Error

func (e *AlreadyExistsError) Error() string

Error returns the error message as a string.

type DB

type DB interface {
	AcceptedTermsURL
	Account
	EphemeralPublicKey
	Token

	// Close closes the db connections
	Close(ctx context.Context) Error
	// DoMigration runs database migrations
	DoMigration(ctx context.Context) Error
}

DB represents a database client.

type EphemeralPublicKey

type EphemeralPublicKey interface {
	CreateEphemeralPublicKey(ctx context.Context, ephemeralPublicKey *models.EphemeralPublicKey) Error
	IncEphemeralPublicKeyVerifyCountByPublicKey(ctx context.Context, publicKey string) (rowsEffected int64, err Error)
}

type Error

type Error error

Error represents a database specific error.

var (
	// ErrGenID is returned when creating a new ID can't be generated for a new model.
	ErrGenID Error = fmt.Errorf("can't generate id")
	// ErrNoEntries is returned when a caller expected an entry for a query, but none was found.
	ErrNoEntries Error = fmt.Errorf("no entries")
	// ErrMultipleEntries is returned when a caller expected ONE entry for a query, but multiples were found.
	ErrMultipleEntries Error = fmt.Errorf("multiple entries")
	// ErrUnknown denotes an unknown database error.
	ErrUnknown Error = fmt.Errorf("unknown error")
)

type Token

type Token interface {
	CreateToken(ctx context.Context, token *models.Token) Error
	ReadTokenByToken(ctx context.Context, token string) (*models.Token, Error)
	DeleteToken(ctx context.Context, token *models.Token) Error
}

Directories

Path Synopsis
bun

Jump to

Keyboard shortcuts

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