database

package
v0.0.0-...-a84335b Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package database provides low-level database connections and querier adapters for the application

Index

Constants

View Source
const (
	// DriverSqlite identifier indicates the sqlite3 driver
	DriverSqlite string = "sqlite3"
)

Variables

This section is empty.

Functions

func IsSchemaUpToDate

func IsSchemaUpToDate(db *sql.DB) error

IsSchemaUpToDate will check that the database is up to date with the expected database schema version

func Migrate

func Migrate(driverName string, db *sql.DB) error

Migrate performes the database migrations on the given database

func NewConn

func NewConn(driver, dsn string) (*sql.DB, error)

NewConn creates a new database connection for the given database driver

func NewSQLiteConn

func NewSQLiteConn(dbFile string) (*sql.DB, error)

NewSQLiteConn creates a new sqlite3 database connection

Types

type AddWishToWishlistParams

type AddWishToWishlistParams struct {
	WishID string `db:"wish_id"`
	ListID string `db:"list_id"`
}

type ApiKey

type ApiKey struct {
	ID        string    `db:"id"`
	ProfileID string    `db:"profile_id"`
	Name      string    `db:"name"`
	Created   time.Time `db:"created"`
}

type CreateAPIKeyParams

type CreateAPIKeyParams struct {
	ID        string `db:"id"`
	ProfileID string `db:"profile_id"`
	Name      string `db:"name"`
}

type CreateGiftExchangeParams

type CreateGiftExchangeParams struct {
	DrawDate     time.Time `db:"draw_date"`
	ExchangeDate time.Time `db:"exchange_date"`
	Title        string    `db:"title"`
	Description  string    `db:"description"`
}

type CreateProfileParams

type CreateProfileParams struct {
	Email     string `db:"email"`
	Name      string `db:"name"`
	InvitedBy string `db:"invited_by"`
}

type CreateSessionInitParams

type CreateSessionInitParams struct {
	ID        string    `db:"id"`
	ProfileID string    `db:"profile_id"`
	Expires   time.Time `db:"expires"`
}

type CreateWishParams

type CreateWishParams struct {
	ProfileID   string `db:"profile_id"`
	Url         string `db:"url"`
	Title       string `db:"title"`
	Description string `db:"description"`
	Quantity    int64  `db:"quantity"`
}

type CreateWishlistParams

type CreateWishlistParams struct {
	ProfileID   string `db:"profile_id"`
	Title       string `db:"title"`
	Description string `db:"description"`
	Visibility  string `db:"visibility"`
}

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 GetWishlistRow

type GetWishlistRow struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Created     time.Time `db:"created"`
	Updated     time.Time `db:"updated"`
	Visibility  string    `db:"visibility"`
	WishesCount int64     `db:"wishes_count"`
}

type GiftExchange

type GiftExchange struct {
	ID           string    `db:"id"`
	DrawDate     time.Time `db:"draw_date"`
	ExchangeDate time.Time `db:"exchange_date"`
	Title        string    `db:"title"`
	Description  string    `db:"description"`
	Created      time.Time `db:"created"`
}

type GiftExchangesProfile

type GiftExchangesProfile struct {
	GiftExchangesID string `db:"gift_exchanges_id"`
	ProfileID       string `db:"profile_id"`
	Owner           bool   `db:"owner"`
}

type InsertWishToWishlistParams

type InsertWishToWishlistParams struct {
	WishID  string `db:"wish_id"`
	ListID  string `db:"list_id"`
	Ordinal int64  `db:"ordinal"`
}

type ListProfileWishlistsRow

type ListProfileWishlistsRow struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Created     time.Time `db:"created"`
	Updated     time.Time `db:"updated"`
	Visibility  string    `db:"visibility"`
	WishesCount int64     `db:"wishes_count"`
}

type ListProfileWishlistsWithVisibilityParams

type ListProfileWishlistsWithVisibilityParams struct {
	ProfileID    string   `db:"profile_id"`
	Visibilities []string `db:"visibilities"`
}

type ListProfileWishlistsWithVisibilityRow

type ListProfileWishlistsWithVisibilityRow struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Created     time.Time `db:"created"`
	Updated     time.Time `db:"updated"`
	Visibility  string    `db:"visibility"`
	WishesCount int64     `db:"wishes_count"`
}

type Profile

type Profile struct {
	ID        string    `db:"id"`
	Email     string    `db:"email"`
	Name      string    `db:"name"`
	Bio       string    `db:"bio"`
	InvitedBy string    `db:"invited_by"`
	Created   time.Time `db:"created"`
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddWishToWishlist

func (q *Queries) AddWishToWishlist(ctx context.Context, arg AddWishToWishlistParams) error

func (*Queries) CountProfiles

func (q *Queries) CountProfiles(ctx context.Context) (int64, error)

func (*Queries) CreateAPIKey

func (q *Queries) CreateAPIKey(ctx context.Context, arg CreateAPIKeyParams) error

func (*Queries) CreateGiftExchange

func (q *Queries) CreateGiftExchange(ctx context.Context, arg CreateGiftExchangeParams) (GiftExchange, error)

func (*Queries) CreateProfile

func (q *Queries) CreateProfile(ctx context.Context, arg CreateProfileParams) (Profile, error)

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, profileID string) (Session, error)

func (*Queries) CreateSessionInit

func (q *Queries) CreateSessionInit(ctx context.Context, arg CreateSessionInitParams) (SessionsInit, error)

func (*Queries) CreateWish

func (q *Queries) CreateWish(ctx context.Context, arg CreateWishParams) (Wish, error)

func (*Queries) CreateWishlist

func (q *Queries) CreateWishlist(ctx context.Context, arg CreateWishlistParams) (Wishlist, error)

func (*Queries) DeleteAPIKey

func (q *Queries) DeleteAPIKey(ctx context.Context, id string) error

func (*Queries) DeleteAllSessions

func (q *Queries) DeleteAllSessions(ctx context.Context, profileID string) error

func (*Queries) DeleteExpiredSessionInit

func (q *Queries) DeleteExpiredSessionInit(ctx context.Context) error

func (*Queries) DeleteGiftExchange

func (q *Queries) DeleteGiftExchange(ctx context.Context, id string) error

func (*Queries) DeleteProfile

func (q *Queries) DeleteProfile(ctx context.Context, id string) error

func (*Queries) DeleteSession

func (q *Queries) DeleteSession(ctx context.Context, id string) error

func (*Queries) DeleteSessionInit

func (q *Queries) DeleteSessionInit(ctx context.Context, id string) error

func (*Queries) DeleteWish

func (q *Queries) DeleteWish(ctx context.Context, id string) error

func (*Queries) DeleteWishlist

func (q *Queries) DeleteWishlist(ctx context.Context, id string) error

func (*Queries) GetExchange

func (q *Queries) GetExchange(ctx context.Context, id string) (GiftExchange, error)

func (*Queries) GetProfile

func (q *Queries) GetProfile(ctx context.Context, id string) (Profile, error)

func (*Queries) GetProfileByEmail

func (q *Queries) GetProfileByEmail(ctx context.Context, email string) (Profile, error)

func (*Queries) GetSession

func (q *Queries) GetSession(ctx context.Context, id string) (Session, error)

func (*Queries) GetSessionInit

func (q *Queries) GetSessionInit(ctx context.Context, id string) (SessionsInit, error)

func (*Queries) GetWish

func (q *Queries) GetWish(ctx context.Context, id string) (Wish, error)

func (*Queries) GetWishlist

func (q *Queries) GetWishlist(ctx context.Context, id string) (GetWishlistRow, error)

func (*Queries) InsertWishToWishlist

func (q *Queries) InsertWishToWishlist(ctx context.Context, arg InsertWishToWishlistParams) error

func (*Queries) ListAPIKeys

func (q *Queries) ListAPIKeys(ctx context.Context, profileID string) ([]ApiKey, error)

func (*Queries) ListGiftExchangeMembers

func (q *Queries) ListGiftExchangeMembers(ctx context.Context, giftExchangesID string) ([]GiftExchangesProfile, error)

func (*Queries) ListGiftExchanges

func (q *Queries) ListGiftExchanges(ctx context.Context) ([]GiftExchange, error)

func (*Queries) ListProfileWishlists

func (q *Queries) ListProfileWishlists(ctx context.Context, profileID string) ([]ListProfileWishlistsRow, error)

func (*Queries) ListProfiles

func (q *Queries) ListProfiles(ctx context.Context) ([]Profile, error)

func (*Queries) ListUnlistedWishes

func (q *Queries) ListUnlistedWishes(ctx context.Context, profileID string) ([]Wish, error)

func (*Queries) RemoveWishFromWishlist

func (q *Queries) RemoveWishFromWishlist(ctx context.Context, arg RemoveWishFromWishlistParams) error

func (*Queries) ShiftWishlistAfterPosition

func (q *Queries) ShiftWishlistAfterPosition(ctx context.Context, arg ShiftWishlistAfterPositionParams) error

func (*Queries) UpdateGiftExchange

func (q *Queries) UpdateGiftExchange(ctx context.Context, arg UpdateGiftExchangeParams) (GiftExchange, error)

func (*Queries) UpdateProfile

func (q *Queries) UpdateProfile(ctx context.Context, arg UpdateProfileParams) (Profile, error)

func (*Queries) UpdateSession

func (q *Queries) UpdateSession(ctx context.Context, arg UpdateSessionParams) (Session, error)

func (*Queries) UpdateWish

func (q *Queries) UpdateWish(ctx context.Context, arg UpdateWishParams) (Wish, error)

func (*Queries) UpdateWishlist

func (q *Queries) UpdateWishlist(ctx context.Context, arg UpdateWishlistParams) (Wishlist, error)

func (*Queries) WishesByWishlist

func (q *Queries) WishesByWishlist(ctx context.Context, listID string) ([]WishesByWishlistRow, error)

func (*Queries) WithTx

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

type RemoveWishFromWishlistParams

type RemoveWishFromWishlistParams struct {
	WishID string `db:"wish_id"`
	ListID string `db:"list_id"`
}

type Session

type Session struct {
	ID        string    `db:"id"`
	ProfileID string    `db:"profile_id"`
	Created   time.Time `db:"created"`
	LastSeen  time.Time `db:"last_seen"`
	State     string    `db:"state"`
}

type SessionsInit

type SessionsInit struct {
	ID        string    `db:"id"`
	ProfileID string    `db:"profile_id"`
	Expires   time.Time `db:"expires"`
}

type ShiftWishlistAfterPositionParams

type ShiftWishlistAfterPositionParams struct {
	ListID  string `db:"list_id"`
	Ordinal int64  `db:"ordinal"`
}

type UpdateGiftExchangeParams

type UpdateGiftExchangeParams struct {
	DrawDate     time.Time `db:"draw_date"`
	ExchangeDate time.Time `db:"exchange_date"`
	Title        string    `db:"title"`
	Description  string    `db:"description"`
	ID           string    `db:"id"`
}

type UpdateProfileParams

type UpdateProfileParams struct {
	Email string `db:"email"`
	Name  string `db:"name"`
	Bio   string `db:"bio"`
	ID    string `db:"id"`
}

type UpdateSessionParams

type UpdateSessionParams struct {
	State string `db:"state"`
	ID    string `db:"id"`
}

type UpdateWishParams

type UpdateWishParams struct {
	Url         string `db:"url"`
	Title       string `db:"title"`
	Description string `db:"description"`
	Quantity    int64  `db:"quantity"`
	ID          string `db:"id"`
}

type UpdateWishlistParams

type UpdateWishlistParams struct {
	Title       string `db:"title"`
	Description string `db:"description"`
	Visibility  string `db:"visibility"`
	ID          string `db:"id"`
}

type Wish

type Wish struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Url         string    `db:"url"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Quantity    int64     `db:"quantity"`
	Created     time.Time `db:"created"`
}

type WishesByWishlistRow

type WishesByWishlistRow struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Url         string    `db:"url"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Quantity    int64     `db:"quantity"`
	Created     time.Time `db:"created"`
	ListID      string    `db:"list_id"`
	Ordinal     int64     `db:"ordinal"`
	AddedDate   time.Time `db:"added_date"`
}

type Wishlist

type Wishlist struct {
	ID          string    `db:"id"`
	ProfileID   string    `db:"profile_id"`
	Title       string    `db:"title"`
	Description string    `db:"description"`
	Created     time.Time `db:"created"`
	Updated     time.Time `db:"updated"`
	Visibility  string    `db:"visibility"`
}

type WishlistsWish

type WishlistsWish struct {
	WishID  string    `db:"wish_id"`
	ListID  string    `db:"list_id"`
	Ordinal int64     `db:"ordinal"`
	Created time.Time `db:"created"`
}

Jump to

Keyboard shortcuts

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