database

package
v0.0.0-...-f212135 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ForeignKeyViolation = "23503"
	UniqueViolation     = "23505"
)

Variables

View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{
	Code: UniqueViolation,
}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type AddFavoritePropertyParams

type AddFavoritePropertyParams struct {
	Email      string `json:"email"`
	PropertyID int64  `json:"property_id"`
}

type BulkInsertPropertyImagesParams

type BulkInsertPropertyImagesParams struct {
	PropertyIds []int64  `json:"property_ids"`
	ImageUrls   []string `json:"image_urls"`
}

type BulkUpsertPropertyListingsParams

type BulkUpsertPropertyListingsParams struct {
	ExternalIds          []string           `json:"external_ids"`
	Addresses            []string           `json:"addresses"`
	Bedrooms             []int32            `json:"bedrooms"`
	Bathrooms            []int32            `json:"bathrooms"`
	PropertyTypes        []string           `json:"property_types"`
	Latitudes            []float64          `json:"latitudes"`
	Longitudes           []float64          `json:"longitudes"`
	Prices               []int32            `json:"prices"`
	AddedDates           []pgtype.Timestamp `json:"added_dates"`
	Reduced              []bool             `json:"reduced"`
	ReducedDates         []pgtype.Timestamp `json:"reduced_dates"`
	AgentNames           []string           `json:"agent_names"`
	AgentBranchNames     []string           `json:"agent_branch_names"`
	AgentContactPhones   []string           `json:"agent_contact_phones"`
	NumberOfImages       []int32            `json:"number_of_images"`
	NumberOfFloorplans   []int32            `json:"number_of_floorplans"`
	NumberOfVirtualTours []int32            `json:"number_of_virtual_tours"`
	MainImageUrls        []string           `json:"main_image_urls"`
	PropertyUrls         []string           `json:"property_urls"`
	SummaryDescriptions  []string           `json:"summary_descriptions"`
	Titles               []string           `json:"titles"`
}

type BulkUpsertPropertyListingsRow

type BulkUpsertPropertyListingsRow struct {
	ID         int64       `json:"id"`
	ExternalID pgtype.Text `json:"external_id"`
}

type CreatePropertyImageParams

type CreatePropertyImageParams struct {
	PropertyID pgtype.Int8 `json:"property_id"`
	ImageUrl   pgtype.Text `json:"image_url"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	Email        string    `json:"email"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type CreateUserParams

type CreateUserParams struct {
	Username     string      `json:"username"`
	Email        string      `json:"email"`
	PasswordHash string      `json:"password_hash"`
	FirstName    pgtype.Text `json:"first_name"`
	LastName     pgtype.Text `json:"last_name"`
}

type DBTX

type DBTX interface {
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
}

type DeleteFavoritePropertyParams

type DeleteFavoritePropertyParams struct {
	Email      string `json:"email"`
	PropertyID int64  `json:"property_id"`
}

type FavoriteProperty

type FavoriteProperty struct {
	ID         int64     `json:"id"`
	Email      string    `json:"email"`
	PropertyID int64     `json:"property_id"`
	CreatedAt  time.Time `json:"created_at"`
}

type GetNewPropertiesParams

type GetNewPropertiesParams struct {
	CreatedAt   time.Time        `json:"created_at"`
	ReducedDate pgtype.Timestamp `json:"reduced_date"`
}

type GetPropertyByExternalIdRow

type GetPropertyByExternalIdRow struct {
	ID                   int64            `json:"id"`
	ExternalID           pgtype.Text      `json:"external_id"`
	Address              pgtype.Text      `json:"address"`
	Bedrooms             pgtype.Int4      `json:"bedrooms"`
	Bathrooms            pgtype.Int4      `json:"bathrooms"`
	PropertyType         pgtype.Text      `json:"property_type"`
	Latitude             pgtype.Numeric   `json:"latitude"`
	Longitude            pgtype.Numeric   `json:"longitude"`
	City                 pgtype.Text      `json:"city"`
	State                pgtype.Text      `json:"state"`
	Country              pgtype.Text      `json:"country"`
	Price                pgtype.Numeric   `json:"price"`
	Added                pgtype.Timestamp `json:"added"`
	Reduced              pgtype.Bool      `json:"reduced"`
	ReducedDate          pgtype.Timestamp `json:"reduced_date"`
	AgentName            pgtype.Text      `json:"agent_name"`
	AgentBranchName      pgtype.Text      `json:"agent_branch_name"`
	AgentContactPhone    pgtype.Text      `json:"agent_contact_phone"`
	NumberOfImages       pgtype.Int4      `json:"number_of_images"`
	NumberOfFloorplans   pgtype.Int4      `json:"number_of_floorplans"`
	NumberOfVirtualTours pgtype.Int4      `json:"number_of_virtual_tours"`
	MainImageUrl         pgtype.Text      `json:"main_image_url"`
	PropertyUrl          pgtype.Text      `json:"property_url"`
	SummaryDescription   pgtype.Text      `json:"summary_description"`
	Title                pgtype.Text      `json:"title"`
	UpdatedAt            time.Time        `json:"updated_at"`
	CreatedAt            time.Time        `json:"created_at"`
	Images               interface{}      `json:"images"`
}

type GetPropertyListingRow

type GetPropertyListingRow struct {
	ID                   int64            `json:"id"`
	ExternalID           pgtype.Text      `json:"external_id"`
	Address              pgtype.Text      `json:"address"`
	Bedrooms             pgtype.Int4      `json:"bedrooms"`
	Bathrooms            pgtype.Int4      `json:"bathrooms"`
	PropertyType         pgtype.Text      `json:"property_type"`
	Latitude             pgtype.Numeric   `json:"latitude"`
	Longitude            pgtype.Numeric   `json:"longitude"`
	City                 pgtype.Text      `json:"city"`
	State                pgtype.Text      `json:"state"`
	Country              pgtype.Text      `json:"country"`
	Price                pgtype.Numeric   `json:"price"`
	Added                pgtype.Timestamp `json:"added"`
	Reduced              pgtype.Bool      `json:"reduced"`
	ReducedDate          pgtype.Timestamp `json:"reduced_date"`
	AgentName            pgtype.Text      `json:"agent_name"`
	AgentBranchName      pgtype.Text      `json:"agent_branch_name"`
	AgentContactPhone    pgtype.Text      `json:"agent_contact_phone"`
	NumberOfImages       pgtype.Int4      `json:"number_of_images"`
	NumberOfFloorplans   pgtype.Int4      `json:"number_of_floorplans"`
	NumberOfVirtualTours pgtype.Int4      `json:"number_of_virtual_tours"`
	MainImageUrl         pgtype.Text      `json:"main_image_url"`
	PropertyUrl          pgtype.Text      `json:"property_url"`
	SummaryDescription   pgtype.Text      `json:"summary_description"`
	Title                pgtype.Text      `json:"title"`
	UpdatedAt            time.Time        `json:"updated_at"`
	CreatedAt            time.Time        `json:"created_at"`
	Images               interface{}      `json:"images"`
}

type ListPropertyListingsParams

type ListPropertyListingsParams struct {
	Limit  int32 `json:"limit"`
	Offset int32 `json:"offset"`
}

type ListPropertyListingsRow

type ListPropertyListingsRow struct {
	ID                   int64            `json:"id"`
	ExternalID           pgtype.Text      `json:"external_id"`
	Address              pgtype.Text      `json:"address"`
	Bedrooms             pgtype.Int4      `json:"bedrooms"`
	Bathrooms            pgtype.Int4      `json:"bathrooms"`
	PropertyType         pgtype.Text      `json:"property_type"`
	Latitude             pgtype.Numeric   `json:"latitude"`
	Longitude            pgtype.Numeric   `json:"longitude"`
	City                 pgtype.Text      `json:"city"`
	State                pgtype.Text      `json:"state"`
	Country              pgtype.Text      `json:"country"`
	Price                pgtype.Numeric   `json:"price"`
	Added                pgtype.Timestamp `json:"added"`
	Reduced              pgtype.Bool      `json:"reduced"`
	ReducedDate          pgtype.Timestamp `json:"reduced_date"`
	AgentName            pgtype.Text      `json:"agent_name"`
	AgentBranchName      pgtype.Text      `json:"agent_branch_name"`
	AgentContactPhone    pgtype.Text      `json:"agent_contact_phone"`
	NumberOfImages       pgtype.Int4      `json:"number_of_images"`
	NumberOfFloorplans   pgtype.Int4      `json:"number_of_floorplans"`
	NumberOfVirtualTours pgtype.Int4      `json:"number_of_virtual_tours"`
	MainImageUrl         pgtype.Text      `json:"main_image_url"`
	PropertyUrl          pgtype.Text      `json:"property_url"`
	SummaryDescription   pgtype.Text      `json:"summary_description"`
	Title                pgtype.Text      `json:"title"`
	UpdatedAt            time.Time        `json:"updated_at"`
	CreatedAt            time.Time        `json:"created_at"`
	Images               interface{}      `json:"images"`
}

type LocationCache

type LocationCache struct {
	ID           int32          `json:"id"`
	LatitudeKey  pgtype.Numeric `json:"latitude_key"`
	LongitudeKey pgtype.Numeric `json:"longitude_key"`
	City         pgtype.Text    `json:"city"`
	State        pgtype.Text    `json:"state"`
	Country      pgtype.Text    `json:"country"`
	CreatedAt    time.Time      `json:"created_at"`
}

type PropertyImage

type PropertyImage struct {
	ID         int64       `json:"id"`
	PropertyID pgtype.Int8 `json:"property_id"`
	ImageUrl   pgtype.Text `json:"image_url"`
}

type PropertyListing

type PropertyListing struct {
	ID                   int64            `json:"id"`
	ExternalID           pgtype.Text      `json:"external_id"`
	Address              pgtype.Text      `json:"address"`
	Bedrooms             pgtype.Int4      `json:"bedrooms"`
	Bathrooms            pgtype.Int4      `json:"bathrooms"`
	PropertyType         pgtype.Text      `json:"property_type"`
	Latitude             pgtype.Numeric   `json:"latitude"`
	Longitude            pgtype.Numeric   `json:"longitude"`
	City                 pgtype.Text      `json:"city"`
	State                pgtype.Text      `json:"state"`
	Country              pgtype.Text      `json:"country"`
	Price                pgtype.Numeric   `json:"price"`
	Added                pgtype.Timestamp `json:"added"`
	Reduced              pgtype.Bool      `json:"reduced"`
	ReducedDate          pgtype.Timestamp `json:"reduced_date"`
	AgentName            pgtype.Text      `json:"agent_name"`
	AgentBranchName      pgtype.Text      `json:"agent_branch_name"`
	AgentContactPhone    pgtype.Text      `json:"agent_contact_phone"`
	NumberOfImages       pgtype.Int4      `json:"number_of_images"`
	NumberOfFloorplans   pgtype.Int4      `json:"number_of_floorplans"`
	NumberOfVirtualTours pgtype.Int4      `json:"number_of_virtual_tours"`
	MainImageUrl         pgtype.Text      `json:"main_image_url"`
	PropertyUrl          pgtype.Text      `json:"property_url"`
	SummaryDescription   pgtype.Text      `json:"summary_description"`
	Title                pgtype.Text      `json:"title"`
	UpdatedAt            time.Time        `json:"updated_at"`
	CreatedAt            time.Time        `json:"created_at"`
}

type Querier

type Querier interface {
	AddFavoriteProperty(ctx context.Context, arg AddFavoritePropertyParams) (FavoriteProperty, error)
	BulkInsertPropertyImages(ctx context.Context, arg BulkInsertPropertyImagesParams) error
	BulkUpsertPropertyListings(ctx context.Context, arg BulkUpsertPropertyListingsParams) ([]BulkUpsertPropertyListingsRow, error)
	CreatePropertyImage(ctx context.Context, arg CreatePropertyImageParams) error
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteFavoriteProperty(ctx context.Context, arg DeleteFavoritePropertyParams) error
	DeletePropertyImages(ctx context.Context, propertyID pgtype.Int8) error
	DeleteUser(ctx context.Context, id int64) error
	GetNewProperties(ctx context.Context, arg GetNewPropertiesParams) ([]PropertyListing, error)
	GetPropertyByExternalId(ctx context.Context, externalID pgtype.Text) (GetPropertyByExternalIdRow, error)
	GetPropertyListing(ctx context.Context, id int64) (GetPropertyListingRow, error)
	GetPropertyListings(ctx context.Context, dollar_1 []int64) ([]PropertyListing, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetTotalPropertyCount(ctx context.Context) (int64, error)
	GetUser(ctx context.Context, id int64) (User, error)
	GetUserByEmail(ctx context.Context, email string) (User, error)
	GetUserByUsername(ctx context.Context, username string) (User, error)
	ListFavoriteProperties(ctx context.Context, email string) ([]PropertyListing, error)
	ListPropertyListings(ctx context.Context, arg ListPropertyListingsParams) ([]ListPropertyListingsRow, error)
	UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) AddFavoriteProperty

func (q *Queries) AddFavoriteProperty(ctx context.Context, arg AddFavoritePropertyParams) (FavoriteProperty, error)

func (*Queries) BulkInsertPropertyImages

func (q *Queries) BulkInsertPropertyImages(ctx context.Context, arg BulkInsertPropertyImagesParams) error

func (*Queries) BulkUpsertPropertyListings

func (q *Queries) BulkUpsertPropertyListings(ctx context.Context, arg BulkUpsertPropertyListingsParams) ([]BulkUpsertPropertyListingsRow, error)

func (*Queries) CreatePropertyImage

func (q *Queries) CreatePropertyImage(ctx context.Context, arg CreatePropertyImageParams) error

func (*Queries) CreateSession

func (q *Queries) CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)

func (*Queries) CreateUser

func (q *Queries) CreateUser(ctx context.Context, arg CreateUserParams) (User, error)

func (*Queries) DeleteFavoriteProperty

func (q *Queries) DeleteFavoriteProperty(ctx context.Context, arg DeleteFavoritePropertyParams) error

func (*Queries) DeletePropertyImages

func (q *Queries) DeletePropertyImages(ctx context.Context, propertyID pgtype.Int8) error

func (*Queries) DeleteUser

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

func (*Queries) GetNewProperties

func (q *Queries) GetNewProperties(ctx context.Context, arg GetNewPropertiesParams) ([]PropertyListing, error)

func (*Queries) GetPropertyByExternalId

func (q *Queries) GetPropertyByExternalId(ctx context.Context, externalID pgtype.Text) (GetPropertyByExternalIdRow, error)

func (*Queries) GetPropertyListing

func (q *Queries) GetPropertyListing(ctx context.Context, id int64) (GetPropertyListingRow, error)

func (*Queries) GetPropertyListings

func (q *Queries) GetPropertyListings(ctx context.Context, dollar_1 []int64) ([]PropertyListing, error)

func (*Queries) GetSession

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

func (*Queries) GetTotalPropertyCount

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

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, id int64) (User, error)

func (*Queries) GetUserByEmail

func (q *Queries) GetUserByEmail(ctx context.Context, email string) (User, error)

func (*Queries) GetUserByUsername

func (q *Queries) GetUserByUsername(ctx context.Context, username string) (User, error)

func (*Queries) ListFavoriteProperties

func (q *Queries) ListFavoriteProperties(ctx context.Context, email string) ([]PropertyListing, error)

func (*Queries) ListPropertyListings

func (q *Queries) ListPropertyListings(ctx context.Context, arg ListPropertyListingsParams) ([]ListPropertyListingsRow, error)

func (*Queries) UpdateUser

func (q *Queries) UpdateUser(ctx context.Context, arg UpdateUserParams) (User, error)

func (*Queries) WithTx

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

type SQLStore

type SQLStore struct {
	Pool *pgxpool.Pool
	*Queries
}

func (*SQLStore) GetPool

func (s *SQLStore) GetPool() *pgxpool.Pool

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	Email        string    `json:"email"`
	RefreshToken string    `json:"refresh_token"`
	UserAgent    string    `json:"user_agent"`
	ClientIp     string    `json:"client_ip"`
	IsBlocked    bool      `json:"is_blocked"`
	ExpiresAt    time.Time `json:"expires_at"`
}

type Store

type Store interface {
	Querier
	GetPool() *pgxpool.Pool
}

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

type UpdateUserParams

type UpdateUserParams struct {
	Username     pgtype.Text `json:"username"`
	Email        pgtype.Text `json:"email"`
	PasswordHash pgtype.Text `json:"password_hash"`
	FirstName    pgtype.Text `json:"first_name"`
	LastName     pgtype.Text `json:"last_name"`
	ID           int64       `json:"id"`
}

type User

type User struct {
	ID           int64       `json:"id"`
	Username     string      `json:"username"`
	Email        string      `json:"email"`
	PasswordHash string      `json:"password_hash"`
	FirstName    pgtype.Text `json:"first_name"`
	LastName     pgtype.Text `json:"last_name"`
	CreatedAt    time.Time   `json:"created_at"`
	UpdatedAt    time.Time   `json:"updated_at"`
}

Jump to

Keyboard shortcuts

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