db

package
v0.0.0-...-c29c528 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

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

Variables

View Source
var ErrRecordNotFound = sql.ErrNoRows
View Source
var ErrUniqueViolation = &pq.Error{
	Code: UniqueViolation,
}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type Account

type Account struct {
	ID             int32     `json:"id"`
	Email          string    `json:"email"`
	HashedPassword string    `json:"hashed_password"`
	CreatedAt      time.Time `json:"created_at"`
}

type Booking

type Booking struct {
	ID                 int64     `json:"id"`
	AccountID          int64     `json:"account_id"`
	UserID             int64     `json:"user_id"`
	CarID              int64     `json:"car_id"`
	BookingDate        time.Time `json:"booking_date"`
	ProblemDescription string    `json:"problem_description"`
	CreatedAt          time.Time `json:"created_at"`
}

type Car

type Car struct {
	ID              int64     `json:"id"`
	UserID          int64     `json:"user_id"`
	CarRegistration string    `json:"car_registration"`
	Make            string    `json:"make"`
	Model           string    `json:"model"`
	FuelType        string    `json:"fuel_type"`
	YearManufacture int32     `json:"year_manufacture"`
	CreatedAt       time.Time `json:"created_at"`
}

type CreateAccountParams

type CreateAccountParams struct {
	Email          string `json:"email"`
	HashedPassword string `json:"hashed_password"`
}

type CreateBookingParams

type CreateBookingParams struct {
	AccountID          int64     `json:"account_id"`
	UserID             int64     `json:"user_id"`
	CarID              int64     `json:"car_id"`
	BookingDate        time.Time `json:"booking_date"`
	ProblemDescription string    `json:"problem_description"`
}

type CreateCarParams

type CreateCarParams struct {
	UserID          int64  `json:"user_id"`
	CarRegistration string `json:"car_registration"`
	Make            string `json:"make"`
	Model           string `json:"model"`
	FuelType        string `json:"fuel_type"`
	YearManufacture int32  `json:"year_manufacture"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID `json:"id"`
	AccountID    int32     `json:"account_id"`
	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"`
	PhoneNumber string `json:"phone_number"`
}

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 DeleteBookingParams

type DeleteBookingParams struct {
	ID        int64 `json:"id"`
	AccountID int64 `json:"account_id"`
}

type GetBookingsRow

type GetBookingsRow struct {
	ID                 int64     `json:"id"`
	AccountID          int64     `json:"account_id"`
	Username           string    `json:"username"`
	Email              string    `json:"email"`
	PhoneNumber        string    `json:"phone_number"`
	CarRegistration    string    `json:"car_registration"`
	Make               string    `json:"make"`
	Model              string    `json:"model"`
	FuelType           string    `json:"fuel_type"`
	YearManufacture    int32     `json:"year_manufacture"`
	BookingDate        time.Time `json:"booking_date"`
	ProblemDescription string    `json:"problem_description"`
	CreatedAt          time.Time `json:"created_at"`
}

type GetCarParams

type GetCarParams struct {
	CarRegistration string `json:"car_registration"`
	UserID          int64  `json:"user_id"`
}

type GetCarsWithUserDetailsParams

type GetCarsWithUserDetailsParams struct {
	Email       string `json:"email"`
	PhoneNumber string `json:"phone_number"`
}

type GetTodaysBookingsRow

type GetTodaysBookingsRow struct {
	ID                 int64     `json:"id"`
	AccountID          int64     `json:"account_id"`
	UserID             int64     `json:"user_id"`
	CarID              int64     `json:"car_id"`
	BookingDate        time.Time `json:"booking_date"`
	ProblemDescription string    `json:"problem_description"`
	CreatedAt          time.Time `json:"created_at"`
	ID_2               int64     `json:"id_2"`
	Username           string    `json:"username"`
	Email              string    `json:"email"`
	PhoneNumber        string    `json:"phone_number"`
	CreatedAt_2        time.Time `json:"created_at_2"`
}

type GetUserParams

type GetUserParams struct {
	Email       string `json:"email"`
	PhoneNumber string `json:"phone_number"`
}

type Querier

type Querier interface {
	CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)
	CreateBooking(ctx context.Context, arg CreateBookingParams) (Booking, error)
	CreateCar(ctx context.Context, arg CreateCarParams) (Car, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteBooking(ctx context.Context, arg DeleteBookingParams) error
	DeleteSession(ctx context.Context, refreshToken string) error
	GetAccount(ctx context.Context, email string) (Account, error)
	GetBookings(ctx context.Context, accountID int64) ([]GetBookingsRow, error)
	GetCar(ctx context.Context, arg GetCarParams) (Car, error)
	GetCars(ctx context.Context, userID int64) ([]Car, error)
	GetCarsWithUserDetails(ctx context.Context, arg GetCarsWithUserDetailsParams) ([]string, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetTodaysBookings(ctx context.Context) ([]GetTodaysBookingsRow, error)
	GetUser(ctx context.Context, arg GetUserParams) (User, error)
	SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)
	UpdateBooking(ctx context.Context, arg UpdateBookingParams) (Booking, error)
}

type Queries

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

func New

func New(db DBTX) *Queries

func (*Queries) CreateAccount

func (q *Queries) CreateAccount(ctx context.Context, arg CreateAccountParams) (Account, error)

func (*Queries) CreateBooking

func (q *Queries) CreateBooking(ctx context.Context, arg CreateBookingParams) (Booking, error)

func (*Queries) CreateCar

func (q *Queries) CreateCar(ctx context.Context, arg CreateCarParams) (Car, 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) DeleteBooking

func (q *Queries) DeleteBooking(ctx context.Context, arg DeleteBookingParams) error

func (*Queries) DeleteSession

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

func (*Queries) GetAccount

func (q *Queries) GetAccount(ctx context.Context, email string) (Account, error)

func (*Queries) GetBookings

func (q *Queries) GetBookings(ctx context.Context, accountID int64) ([]GetBookingsRow, error)

func (*Queries) GetCar

func (q *Queries) GetCar(ctx context.Context, arg GetCarParams) (Car, error)

func (*Queries) GetCars

func (q *Queries) GetCars(ctx context.Context, userID int64) ([]Car, error)

func (*Queries) GetCarsWithUserDetails

func (q *Queries) GetCarsWithUserDetails(ctx context.Context, arg GetCarsWithUserDetailsParams) ([]string, error)

func (*Queries) GetSession

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

func (*Queries) GetTodaysBookings

func (q *Queries) GetTodaysBookings(ctx context.Context) ([]GetTodaysBookingsRow, error)

func (*Queries) GetUser

func (q *Queries) GetUser(ctx context.Context, arg GetUserParams) (User, error)

func (*Queries) SearchUsers

func (q *Queries) SearchUsers(ctx context.Context, arg SearchUsersParams) ([]SearchUsersRow, error)

func (*Queries) UpdateBooking

func (q *Queries) UpdateBooking(ctx context.Context, arg UpdateBookingParams) (Booking, error)

func (*Queries) WithTx

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

type SQLStore

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

type SearchUsersParams

type SearchUsersParams struct {
	WordSimilarity   string `json:"word_similarity"`
	WordSimilarity_2 string `json:"word_similarity_2"`
	WordSimilarity_3 string `json:"word_similarity_3"`
}

type SearchUsersRow

type SearchUsersRow struct {
	ID          int64     `json:"id"`
	Username    string    `json:"username"`
	Email       string    `json:"email"`
	PhoneNumber string    `json:"phone_number"`
	CreatedAt   time.Time `json:"created_at"`
	CombinedSim float64   `json:"combined_sim"`
}

type Session

type Session struct {
	ID           uuid.UUID `json:"id"`
	AccountID    int32     `json:"account_id"`
	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"`
	CreatedAt    time.Time `json:"created_at"`
}

type Store

type Store interface {
	Querier
}

func NewStore

func NewStore(db *sql.DB) Store

type UpdateBookingParams

type UpdateBookingParams struct {
	UserID             int64     `json:"user_id"`
	CarID              int64     `json:"car_id"`
	BookingDate        time.Time `json:"booking_date"`
	ProblemDescription string    `json:"problem_description"`
	ID                 int64     `json:"id"`
	AccountID          int64     `json:"account_id"`
}

type User

type User struct {
	ID          int64     `json:"id"`
	Username    string    `json:"username"`
	Email       string    `json:"email"`
	PhoneNumber string    `json:"phone_number"`
	CreatedAt   time.Time `json:"created_at"`
}

Jump to

Keyboard shortcuts

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