store

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunUnitOfWork

func RunUnitOfWork[T any](
	ctx context.Context,
	repo TxBeginner,
	fn WorkFn[T],
) (T, error)

Types

type APIKey

type APIKey struct {
	ID          uuid.UUID `json:"id" db:"id"`
	ClientID    uuid.UUID `json:"-" db:"client_id"`
	Description *string   `json:"description" db:"description"`
	Prefix      string    `json:"prefix" db:"prefix"`
	Hash        string    `json:"-" db:"hash"`
	CreatedAt   time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt   time.Time `json:"updatedAt" db:"updated_at"`
}

type AuthRepository

type AuthRepository interface {
	GetUserPasswordHash(userID uuid.UUID, opts QueryOptions) (string, error)
}

type Client

type Client struct {
	ID        uuid.UUID `json:"id" db:"id"`
	Name      string    `json:"name" db:"name"`
	Enabled   bool      `json:"enabled" db:"enabled"`
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}

type ClientPatch

type ClientPatch struct {
	Name    *string
	Enabled *bool
}

func (ClientPatch) ApplyTo

func (p ClientPatch) ApplyTo(client Client) Client

type ClientRepository

type ClientRepository interface {
	ListClients(opts QueryOptions) ([]Client, error)
	GetClientById(id uuid.UUID, opts QueryOptions) (Client, error)
	InsertClient(user NewClient, opts QueryOptions) (uuid.UUID, error)
	SaveClient(user Client, opts QueryOptions) error
	DeleteClient(id uuid.UUID, opts QueryOptions) error

	GetClientAPIKey(clientID uuid.UUID, prefix string, opts QueryOptions) (APIKey, error)
	ListClientAPIKeys(clientID uuid.UUID, opts QueryOptions) ([]APIKey, error)
	InsertAPIKey(key NewAPIKey, opts QueryOptions) (uuid.UUID, error)
	DeleteClientAPIKey(clientID, keyID uuid.UUID, opts QueryOptions) error
}

type Email

type Email struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	Email     string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type EmailRepository

type EmailRepository interface {
	InsertEmail(email NewEmail, opts QueryOptions) (uuid.UUID, error)
}

type NewAPIKey

type NewAPIKey struct {
	ClientID    uuid.UUID
	Description *string
	Prefix      string
	Hash        string
}

type NewClient

type NewClient struct {
	Name    string
	Enabled bool
}

type NewEmail

type NewEmail struct {
	UserID uuid.UUID
	Email  string
}

type NewPassword

type NewPassword struct {
	UserID uuid.UUID
	Hash   string
}

type NewUser

type NewUser struct {
	FirstName string
	LastName  string
	Email     string
	Password  *string
}

type NotFoundError

type NotFoundError struct {
	ResourceType string
	ResourceID   string
}

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Password

type Password struct {
	ID        uuid.UUID
	UserID    uuid.UUID
	Hash      string
	CreatedAt time.Time
	UpdatedAt time.Time
}

type PasswordRepository

type PasswordRepository interface {
	InsertPassword(password NewPassword, opts QueryOptions) (uuid.UUID, error)
}

type QueryOptions

type QueryOptions struct {
	Ctx context.Context
	Txn *sqlx.Tx
}

func (*QueryOptions) Context

func (q *QueryOptions) Context() context.Context

type Session

type Session struct {
	Token     string    `json:"token" db:"token"`
	UserId    uuid.UUID `json:"userId" db:"user_id"`
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	ExpiresAt time.Time `json:"expiresAt" db:"expires_at"`
}

type SessionRepository

type SessionRepository interface {
	GetSession(token string, opts QueryOptions) (Session, error)
	SaveSession(session Session, opts QueryOptions) error
	DeleteSession(token string, opts QueryOptions) error
}

type TxBeginner

type TxBeginner interface {
	BeginTx(xtx context.Context) (*sqlx.Tx, error)
}

type User

type User struct {
	ID        uuid.UUID `json:"id" db:"id"`
	FirstName string    `json:"firstName" db:"first_name"`
	LastName  string    `json:"lastName" db:"last_name"`
	CreatedAt time.Time `json:"createdAt" db:"created_at"`
	UpdatedAt time.Time `json:"updatedAt" db:"updated_at"`
}

type UserPatch

type UserPatch struct {
	FirstName *string
	LastName  *string
}

func (UserPatch) ApplyTo

func (p UserPatch) ApplyTo(user User) User

type UserRepository

type UserRepository interface {
	ListUsers(opts QueryOptions) ([]User, error)
	GetUserById(id uuid.UUID, opts QueryOptions) (User, error)
	GetUserByEmail(email string, opts QueryOptions) (User, error)
	InsertUser(user NewUser, opts QueryOptions) (uuid.UUID, error)
	SaveUser(user User, opts QueryOptions) error
	DeleteUser(id uuid.UUID, opts QueryOptions) error
}

type WorkFn

type WorkFn[T any] func(*sqlx.Tx) (T, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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