db

package
v0.0.0-...-d64ad05 Latest Latest
Warning

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

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

Documentation

Index

Constants

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

Variables

View Source
var (
	ErrBatchAlreadyClosed = errors.New("batch already closed")
)
View Source
var ErrRecordNotFound = pgx.ErrNoRows
View Source
var ErrUniqueViolation = &pgconn.PgError{
	Code: UniqueViolation,
}

Functions

func ErrorCode

func ErrorCode(err error) string

Types

type BatchCreateUserRolesBatchResults

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

func (*BatchCreateUserRolesBatchResults) Close

func (*BatchCreateUserRolesBatchResults) QueryRow

func (b *BatchCreateUserRolesBatchResults) QueryRow(f func(int, RoleUser, error))

type BatchCreateUserRolesParams

type BatchCreateUserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

type BatchDeleteUserRolesBatchResults

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

func (*BatchDeleteUserRolesBatchResults) Close

func (*BatchDeleteUserRolesBatchResults) Exec

func (b *BatchDeleteUserRolesBatchResults) Exec(f func(int, error))

type BatchDeleteUserRolesParams

type BatchDeleteUserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

type CountObservationsParams

type CountObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountStationObservationsParams

type CountStationObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
}

type CountStationsWithinBBoxParams

type CountStationsWithinBBoxParams struct {
	Xmin   float32     `json:"xmin"`
	Ymin   float32     `json:"ymin"`
	Xmax   float32     `json:"xmax"`
	Ymax   float32     `json:"ymax"`
	Status pgtype.Text `json:"status"`
}

type CountStationsWithinRadiusParams

type CountStationsWithinRadiusParams struct {
	Cx     float32     `json:"cx"`
	Cy     float32     `json:"cy"`
	R      float32     `json:"r"`
	Status pgtype.Text `json:"status"`
}

type CreateCurrentObservationParams

type CreateCurrentObservationParams struct {
	StationID     int64              `json:"station_id"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
}

type CreateGLabsLoadParams

type CreateGLabsLoadParams struct {
	Promo         pgtype.Text `json:"promo"`
	TransactionID pgtype.Int4 `json:"transaction_id"`
	Status        pgtype.Text `json:"status"`
	MobileNumber  string      `json:"mobile_number"`
}

type CreateRoleParams

type CreateRoleParams struct {
	Name        string      `json:"name"`
	Description pgtype.Text `json:"description"`
}

type CreateSessionParams

type CreateSessionParams struct {
	ID           uuid.UUID          `json:"id"`
	UserID       int64              `json:"user_id"`
	RefreshToken string             `json:"refresh_token"`
	UserAgent    string             `json:"user_agent"`
	ClientIp     string             `json:"client_ip"`
	IsBlocked    bool               `json:"is_blocked"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
}

type CreateSimAccessTokenParams

type CreateSimAccessTokenParams struct {
	AccessToken  string `json:"access_token"`
	Type         string `json:"type"`
	MobileNumber string `json:"mobile_number"`
}

type CreateSimCardParams

type CreateSimCardParams struct {
	MobileNumber string      `json:"mobile_number"`
	Type         pgtype.Text `json:"type"`
}

type CreateStationHealthParams

type CreateStationHealthParams struct {
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	StationID         int64              `json:"station_id"`
}

type CreateStationObservationParams

type CreateStationObservationParams struct {
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Mslp      pgtype.Float4      `json:"mslp"`
	Hi        pgtype.Float4      `json:"hi"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	QcLevel   int32              `json:"qc_level"`
	StationID int64              `json:"station_id"`
}

type CreateStationParams

type CreateStationParams struct {
	Name          string        `json:"name"`
	Elevation     pgtype.Float4 `json:"elevation"`
	DateInstalled pgtype.Date   `json:"date_installed"`
	MoStationID   pgtype.Text   `json:"mo_station_id"`
	SmsSystemType pgtype.Text   `json:"sms_system_type"`
	MobileNumber  pgtype.Text   `json:"mobile_number"`
	StationType   pgtype.Text   `json:"station_type"`
	StationType2  pgtype.Text   `json:"station_type2"`
	StationUrl    pgtype.Text   `json:"station_url"`
	Status        pgtype.Text   `json:"status"`
	LoggerVersion pgtype.Text   `json:"logger_version"`
	PriorityLevel pgtype.Text   `json:"priority_level"`
	ProviderID    pgtype.Text   `json:"provider_id"`
	Province      pgtype.Text   `json:"province"`
	Region        pgtype.Text   `json:"region"`
	Address       pgtype.Text   `json:"address"`
	Lat           pgtype.Float4 `json:"lat"`
	Lon           pgtype.Float4 `json:"lon"`
}

type CreateUserParams

type CreateUserParams struct {
	Username string `json:"username"`
	Password string `json:"password"`
	FullName string `json:"full_name"`
	Email    string `json:"email"`
}

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
	SendBatch(context.Context, *pgx.Batch) pgx.BatchResults
}

type DeleteStationHealthParams

type DeleteStationHealthParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type DeleteStationObservationParams

type DeleteStationObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type FirstOrCreateSimAccessTokenTxParams

type FirstOrCreateSimAccessTokenTxParams struct {
	MobileNumber     string      `json:"mobile_number"`
	MobileNumberType pgtype.Text `json:"mobile_number_type"`
	AccessToken      string      `json:"access_token"`
	AccessTokenType  string      `json:"access_token_type"`
}

type FirstOrCreateSimAccessTokenTxResult

type FirstOrCreateSimAccessTokenTxResult struct {
	AccessToken SimAccessToken
	IsCreated   bool
}

type GetLatestStationObservationRow

type GetLatestStationObservationRow struct {
	ID                  int64               `json:"id"`
	Name                string              `json:"name"`
	Lat                 pgtype.Float4       `json:"lat"`
	Lon                 pgtype.Float4       `json:"lon"`
	Elevation           pgtype.Float4       `json:"elevation"`
	Address             pgtype.Text         `json:"address"`
	ObservationsCurrent ObservationsCurrent `json:"observations_current"`
}

type GetNearestLatestStationObservationParams

type GetNearestLatestStationObservationParams struct {
	Lon float32 `json:"lon"`
	Lat float32 `json:"lat"`
}

type GetNearestLatestStationObservationRow

type GetNearestLatestStationObservationRow struct {
	ID                  int64               `json:"id"`
	Name                string              `json:"name"`
	Lat                 pgtype.Float4       `json:"lat"`
	Lon                 pgtype.Float4       `json:"lon"`
	Elevation           pgtype.Float4       `json:"elevation"`
	Address             pgtype.Text         `json:"address"`
	ObservationsCurrent ObservationsCurrent `json:"observations_current"`
}

type GetStationHealthParams

type GetStationHealthParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type GetStationObservationParams

type GetStationObservationParams struct {
	StationID int64 `json:"station_id"`
	ID        int64 `json:"id"`
}

type GlabsLoad

type GlabsLoad struct {
	ID            int64              `json:"id"`
	Status        pgtype.Text        `json:"status"`
	Promo         pgtype.Text        `json:"promo"`
	TransactionID pgtype.Int4        `json:"transaction_id"`
	MobileNumber  string             `json:"mobile_number"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
}

type ListLatestObservationsRow

type ListLatestObservationsRow struct {
	ID            int64              `json:"id"`
	Name          string             `json:"name"`
	Lat           pgtype.Float4      `json:"lat"`
	Lon           pgtype.Float4      `json:"lon"`
	Elevation     pgtype.Float4      `json:"elevation"`
	Address       pgtype.Text        `json:"address"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
	Rn            int64              `json:"rn"`
}

type ListLufftStationMsgParams

type ListLufftStationMsgParams struct {
	StationID int64 `json:"station_id"`
	Limit     int32 `json:"limit"`
	Offset    int32 `json:"offset"`
}

type ListLufftStationMsgRow

type ListLufftStationMsgRow struct {
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Message   pgtype.Text        `json:"message"`
}

type ListObservationsParams

type ListObservationsParams struct {
	StationIds  []int64            `json:"station_ids"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListRolesParams

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

type ListStationHealthsParams

type ListStationHealthsParams struct {
	StationID int64 `json:"station_id"`
	Limit     int32 `json:"limit"`
	Offset    int32 `json:"offset"`
}

type ListStationObservationsParams

type ListStationObservationsParams struct {
	StationID   int64              `json:"station_id"`
	IsStartDate bool               `json:"is_start_date"`
	StartDate   pgtype.Timestamptz `json:"start_date"`
	IsEndDate   bool               `json:"is_end_date"`
	EndDate     pgtype.Timestamptz `json:"end_date"`
	Offset      int32              `json:"offset"`
	Limit       pgtype.Int4        `json:"limit"`
}

type ListStationsParams

type ListStationsParams struct {
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListStationsWithinBBoxParams

type ListStationsWithinBBoxParams struct {
	Xmin   float32     `json:"xmin"`
	Ymin   float32     `json:"ymin"`
	Xmax   float32     `json:"xmax"`
	Ymax   float32     `json:"ymax"`
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListStationsWithinRadiusParams

type ListStationsWithinRadiusParams struct {
	Cx     float32     `json:"cx"`
	Cy     float32     `json:"cy"`
	R      float32     `json:"r"`
	Status pgtype.Text `json:"status"`
	Offset int32       `json:"offset"`
	Limit  pgtype.Int4 `json:"limit"`
}

type ListUsersParams

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

type ObservationsCurrent

type ObservationsCurrent struct {
	ID            int64              `json:"id"`
	StationID     int64              `json:"station_id"`
	Rain          pgtype.Float4      `json:"rain"`
	Temp          pgtype.Float4      `json:"temp"`
	Rh            pgtype.Float4      `json:"rh"`
	Wdir          pgtype.Float4      `json:"wdir"`
	Wspd          pgtype.Float4      `json:"wspd"`
	Srad          pgtype.Float4      `json:"srad"`
	Mslp          pgtype.Float4      `json:"mslp"`
	Tn            pgtype.Float4      `json:"tn"`
	Tx            pgtype.Float4      `json:"tx"`
	Gust          pgtype.Float4      `json:"gust"`
	RainAccum     pgtype.Float4      `json:"rain_accum"`
	Timestamp     pgtype.Timestamptz `json:"timestamp"`
	TnTimestamp   pgtype.Timestamptz `json:"tn_timestamp"`
	TxTimestamp   pgtype.Timestamptz `json:"tx_timestamp"`
	GustTimestamp pgtype.Timestamptz `json:"gust_timestamp"`
}

type ObservationsMoObservation

type ObservationsMoObservation struct {
	ID        int64              `json:"id"`
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Hi        pgtype.Float4      `json:"hi"`
	StationID int64              `json:"station_id"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Rain      pgtype.Float4      `json:"rain"`
	Tx        pgtype.Float4      `json:"tx"`
	Tn        pgtype.Float4      `json:"tn"`
	Wrun      pgtype.Float4      `json:"wrun"`
	Thwi      pgtype.Float4      `json:"thwi"`
	Thswi     pgtype.Float4      `json:"thswi"`
	Senergy   pgtype.Float4      `json:"senergy"`
	Sradx     pgtype.Float4      `json:"sradx"`
	Uvi       pgtype.Float4      `json:"uvi"`
	Uvdose    pgtype.Float4      `json:"uvdose"`
	Uvx       pgtype.Float4      `json:"uvx"`
	Hdd       pgtype.Float4      `json:"hdd"`
	Cdd       pgtype.Float4      `json:"cdd"`
	Et        pgtype.Float4      `json:"et"`
	QcLevel   int32              `json:"qc_level"`
	Wdirx     pgtype.Float4      `json:"wdirx"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type ObservationsObservation

type ObservationsObservation struct {
	ID        int64              `json:"id"`
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Mslp      pgtype.Float4      `json:"mslp"`
	Hi        pgtype.Float4      `json:"hi"`
	StationID int64              `json:"station_id"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	Wchill    pgtype.Float4      `json:"wchill"`
	QcLevel   int32              `json:"qc_level"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type ObservationsStation

type ObservationsStation struct {
	ID            int64              `json:"id"`
	Name          string             `json:"name"`
	Lat           pgtype.Float4      `json:"lat"`
	Lon           pgtype.Float4      `json:"lon"`
	Elevation     pgtype.Float4      `json:"elevation"`
	DateInstalled pgtype.Date        `json:"date_installed"`
	MoStationID   pgtype.Text        `json:"mo_station_id"`
	SmsSystemType pgtype.Text        `json:"sms_system_type"`
	MobileNumber  pgtype.Text        `json:"mobile_number"`
	StationType   pgtype.Text        `json:"station_type"`
	StationType2  pgtype.Text        `json:"station_type2"`
	StationUrl    pgtype.Text        `json:"station_url"`
	Status        pgtype.Text        `json:"status"`
	LoggerVersion pgtype.Text        `json:"logger_version"`
	PriorityLevel pgtype.Text        `json:"priority_level"`
	ProviderID    pgtype.Text        `json:"provider_id"`
	Province      pgtype.Text        `json:"province"`
	Region        pgtype.Text        `json:"region"`
	Address       pgtype.Text        `json:"address"`
	CreatedAt     pgtype.Timestamptz `json:"created_at"`
	UpdatedAt     pgtype.Timestamptz `json:"updated_at"`
	DeletedAt     pgtype.Timestamptz `json:"deleted_at"`
	Geom          util.Point         `json:"geom"`
}

type ObservationsStationhealth

type ObservationsStationhealth struct {
	ID                int64              `json:"id"`
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	StationID         int64              `json:"station_id"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
}

type Querier

type Querier interface {
	BatchCreateUserRoles(ctx context.Context, arg []BatchCreateUserRolesParams) *BatchCreateUserRolesBatchResults
	BatchDeleteUserRoles(ctx context.Context, arg []BatchDeleteUserRolesParams) *BatchDeleteUserRolesBatchResults
	CountLufftStationMsg(ctx context.Context, stationID int64) (int64, error)
	CountObservations(ctx context.Context, arg CountObservationsParams) (int64, error)
	CountRoles(ctx context.Context) (int64, error)
	CountStationObservations(ctx context.Context, arg CountStationObservationsParams) (int64, error)
	CountStations(ctx context.Context, status pgtype.Text) (int64, error)
	CountStationsWithinBBox(ctx context.Context, arg CountStationsWithinBBoxParams) (int64, error)
	CountStationsWithinRadius(ctx context.Context, arg CountStationsWithinRadiusParams) (int64, error)
	CountUsers(ctx context.Context) (int64, error)
	CreateCurrentObservation(ctx context.Context, arg CreateCurrentObservationParams) (ObservationsCurrent, error)
	CreateGLabsLoad(ctx context.Context, arg CreateGLabsLoadParams) (GlabsLoad, error)
	CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)
	CreateSession(ctx context.Context, arg CreateSessionParams) (Session, error)
	CreateSimAccessToken(ctx context.Context, arg CreateSimAccessTokenParams) (SimAccessToken, error)
	CreateSimCard(ctx context.Context, arg CreateSimCardParams) (SimCard, error)
	CreateStation(ctx context.Context, arg CreateStationParams) (ObservationsStation, error)
	CreateStationHealth(ctx context.Context, arg CreateStationHealthParams) (ObservationsStationhealth, error)
	CreateStationObservation(ctx context.Context, arg CreateStationObservationParams) (ObservationsObservation, error)
	CreateUser(ctx context.Context, arg CreateUserParams) (User, error)
	DeleteRole(ctx context.Context, id int64) error
	DeleteSession(ctx context.Context, id uuid.UUID) error
	DeleteSimAccessToken(ctx context.Context, accessToken string) error
	DeleteStation(ctx context.Context, id int64) error
	DeleteStationHealth(ctx context.Context, arg DeleteStationHealthParams) error
	DeleteStationObservation(ctx context.Context, arg DeleteStationObservationParams) error
	DeleteUser(ctx context.Context, id int64) error
	GetLatestStationObservation(ctx context.Context, id int64) (GetLatestStationObservationRow, error)
	GetNearestLatestStationObservation(ctx context.Context, arg GetNearestLatestStationObservationParams) (GetNearestLatestStationObservationRow, error)
	GetRole(ctx context.Context, id int64) (Role, error)
	GetRoleByName(ctx context.Context, name string) (Role, error)
	GetSession(ctx context.Context, id uuid.UUID) (Session, error)
	GetSimAccessToken(ctx context.Context, accessToken string) (SimAccessToken, error)
	GetSimCard(ctx context.Context, mobileNumber string) (SimCard, error)
	GetStation(ctx context.Context, id int64) (ObservationsStation, error)
	GetStationByMobileNumber(ctx context.Context, mobileNumber pgtype.Text) (ObservationsStation, error)
	GetStationHealth(ctx context.Context, arg GetStationHealthParams) (ObservationsStationhealth, error)
	GetStationObservation(ctx context.Context, arg GetStationObservationParams) (ObservationsObservation, 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)
	InsertCurrentObservations(ctx context.Context) ([]ObservationsCurrent, error)
	ListLatestObservations(ctx context.Context) ([]ListLatestObservationsRow, error)
	ListLufftStationMsg(ctx context.Context, arg ListLufftStationMsgParams) ([]ListLufftStationMsgRow, error)
	ListObservations(ctx context.Context, arg ListObservationsParams) ([]ObservationsObservation, error)
	ListRoles(ctx context.Context, arg ListRolesParams) ([]Role, error)
	ListStationHealths(ctx context.Context, arg ListStationHealthsParams) ([]ObservationsStationhealth, error)
	ListStationObservations(ctx context.Context, arg ListStationObservationsParams) ([]ObservationsObservation, error)
	ListStations(ctx context.Context, arg ListStationsParams) ([]ObservationsStation, error)
	ListStationsWithinBBox(ctx context.Context, arg ListStationsWithinBBoxParams) ([]ObservationsStation, error)
	ListStationsWithinRadius(ctx context.Context, arg ListStationsWithinRadiusParams) ([]ObservationsStation, error)
	ListUserRoles(ctx context.Context, userID int64) ([]string, error)
	ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)
	UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)
	UpdateStation(ctx context.Context, arg UpdateStationParams) (ObservationsStation, error)
	UpdateStationHealth(ctx context.Context, arg UpdateStationHealthParams) (ObservationsStationhealth, error)
	UpdateStationObservation(ctx context.Context, arg UpdateStationObservationParams) (ObservationsObservation, 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) BatchCreateUserRoles

func (*Queries) BatchDeleteUserRoles

func (*Queries) CountLufftStationMsg

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

func (*Queries) CountObservations

func (q *Queries) CountObservations(ctx context.Context, arg CountObservationsParams) (int64, error)

func (*Queries) CountRoles

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

func (*Queries) CountStationObservations

func (q *Queries) CountStationObservations(ctx context.Context, arg CountStationObservationsParams) (int64, error)

func (*Queries) CountStations

func (q *Queries) CountStations(ctx context.Context, status pgtype.Text) (int64, error)

func (*Queries) CountStationsWithinBBox

func (q *Queries) CountStationsWithinBBox(ctx context.Context, arg CountStationsWithinBBoxParams) (int64, error)

func (*Queries) CountStationsWithinRadius

func (q *Queries) CountStationsWithinRadius(ctx context.Context, arg CountStationsWithinRadiusParams) (int64, error)

func (*Queries) CountUsers

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

func (*Queries) CreateCurrentObservation

func (q *Queries) CreateCurrentObservation(ctx context.Context, arg CreateCurrentObservationParams) (ObservationsCurrent, error)

func (*Queries) CreateGLabsLoad

func (q *Queries) CreateGLabsLoad(ctx context.Context, arg CreateGLabsLoadParams) (GlabsLoad, error)

func (*Queries) CreateRole

func (q *Queries) CreateRole(ctx context.Context, arg CreateRoleParams) (Role, error)

func (*Queries) CreateSession

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

func (*Queries) CreateSimAccessToken

func (q *Queries) CreateSimAccessToken(ctx context.Context, arg CreateSimAccessTokenParams) (SimAccessToken, error)

func (*Queries) CreateSimCard

func (q *Queries) CreateSimCard(ctx context.Context, arg CreateSimCardParams) (SimCard, error)

func (*Queries) CreateStation

func (q *Queries) CreateStation(ctx context.Context, arg CreateStationParams) (ObservationsStation, error)

func (*Queries) CreateStationHealth

func (*Queries) CreateStationObservation

func (q *Queries) CreateStationObservation(ctx context.Context, arg CreateStationObservationParams) (ObservationsObservation, error)

func (*Queries) CreateUser

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

func (*Queries) DeleteRole

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

func (*Queries) DeleteSession

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

func (*Queries) DeleteSimAccessToken

func (q *Queries) DeleteSimAccessToken(ctx context.Context, accessToken string) error

func (*Queries) DeleteStation

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

func (*Queries) DeleteStationHealth

func (q *Queries) DeleteStationHealth(ctx context.Context, arg DeleteStationHealthParams) error

func (*Queries) DeleteStationObservation

func (q *Queries) DeleteStationObservation(ctx context.Context, arg DeleteStationObservationParams) error

func (*Queries) DeleteUser

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

func (*Queries) GetLatestStationObservation

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

func (*Queries) GetRole

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

func (*Queries) GetRoleByName

func (q *Queries) GetRoleByName(ctx context.Context, name string) (Role, error)

func (*Queries) GetSession

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

func (*Queries) GetSimAccessToken

func (q *Queries) GetSimAccessToken(ctx context.Context, accessToken string) (SimAccessToken, error)

func (*Queries) GetSimCard

func (q *Queries) GetSimCard(ctx context.Context, mobileNumber string) (SimCard, error)

func (*Queries) GetStation

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

func (*Queries) GetStationByMobileNumber

func (q *Queries) GetStationByMobileNumber(ctx context.Context, mobileNumber pgtype.Text) (ObservationsStation, error)

func (*Queries) GetStationHealth

func (*Queries) GetStationObservation

func (q *Queries) GetStationObservation(ctx context.Context, arg GetStationObservationParams) (ObservationsObservation, 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) InsertCurrentObservations

func (q *Queries) InsertCurrentObservations(ctx context.Context) ([]ObservationsCurrent, error)

func (*Queries) ListLatestObservations

func (q *Queries) ListLatestObservations(ctx context.Context) ([]ListLatestObservationsRow, error)

func (*Queries) ListLufftStationMsg

func (q *Queries) ListLufftStationMsg(ctx context.Context, arg ListLufftStationMsgParams) ([]ListLufftStationMsgRow, error)

func (*Queries) ListObservations

func (q *Queries) ListObservations(ctx context.Context, arg ListObservationsParams) ([]ObservationsObservation, error)

func (*Queries) ListRoles

func (q *Queries) ListRoles(ctx context.Context, arg ListRolesParams) ([]Role, error)

func (*Queries) ListStationHealths

func (q *Queries) ListStationHealths(ctx context.Context, arg ListStationHealthsParams) ([]ObservationsStationhealth, error)

func (*Queries) ListStationObservations

func (q *Queries) ListStationObservations(ctx context.Context, arg ListStationObservationsParams) ([]ObservationsObservation, error)

func (*Queries) ListStations

func (q *Queries) ListStations(ctx context.Context, arg ListStationsParams) ([]ObservationsStation, error)

func (*Queries) ListStationsWithinBBox

func (q *Queries) ListStationsWithinBBox(ctx context.Context, arg ListStationsWithinBBoxParams) ([]ObservationsStation, error)

func (*Queries) ListStationsWithinRadius

func (q *Queries) ListStationsWithinRadius(ctx context.Context, arg ListStationsWithinRadiusParams) ([]ObservationsStation, error)

func (*Queries) ListUserRoles

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

func (*Queries) ListUsers

func (q *Queries) ListUsers(ctx context.Context, arg ListUsersParams) ([]User, error)

func (*Queries) UpdateRole

func (q *Queries) UpdateRole(ctx context.Context, arg UpdateRoleParams) (Role, error)

func (*Queries) UpdateStation

func (q *Queries) UpdateStation(ctx context.Context, arg UpdateStationParams) (ObservationsStation, error)

func (*Queries) UpdateStationHealth

func (*Queries) UpdateStationObservation

func (q *Queries) UpdateStationObservation(ctx context.Context, arg UpdateStationObservationParams) (ObservationsObservation, 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 Role

type Role struct {
	ID          int64              `json:"id"`
	Name        string             `json:"name"`
	Description pgtype.Text        `json:"description"`
	CreatedAt   pgtype.Timestamptz `json:"created_at"`
	UpdatedAt   pgtype.Timestamptz `json:"updated_at"`
}

type RoleUser

type RoleUser struct {
	RoleID    int64              `json:"role_id"`
	UserID    int64              `json:"user_id"`
	CreatedAt pgtype.Timestamptz `json:"created_at"`
	UpdatedAt pgtype.Timestamptz `json:"updated_at"`
}

type SQLStore

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

SQLStore provides all functions to execute SQL queries and transactions

func (*SQLStore) BulkCreateUserRoles

func (s *SQLStore) BulkCreateUserRoles(ctx context.Context, arg []UserRolesParams) (ret []UserRolesParams, errs []error)

func (*SQLStore) BulkDeleteUserRoles

func (s *SQLStore) BulkDeleteUserRoles(ctx context.Context, arg []UserRolesParams) []error

type Session

type Session struct {
	ID           uuid.UUID          `json:"id"`
	UserID       int64              `json:"user_id"`
	RefreshToken string             `json:"refresh_token"`
	UserAgent    string             `json:"user_agent"`
	ClientIp     string             `json:"client_ip"`
	IsBlocked    bool               `json:"is_blocked"`
	ExpiresAt    pgtype.Timestamptz `json:"expires_at"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
}

type SimAccessToken

type SimAccessToken struct {
	AccessToken  string             `json:"access_token"`
	Type         string             `json:"type"`
	MobileNumber string             `json:"mobile_number"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type SimCard

type SimCard struct {
	MobileNumber string             `json:"mobile_number"`
	Type         pgtype.Text        `json:"type"`
	CreatedAt    pgtype.Timestamptz `json:"created_at"`
	UpdatedAt    pgtype.Timestamptz `json:"updated_at"`
}

type Store

type Store interface {
	Querier
	FirstOrCreateSimAccessTokenTx(ctx context.Context, arg FirstOrCreateSimAccessTokenTxParams) (FirstOrCreateSimAccessTokenTxResult, error)
	BulkCreateUserRoles(ctx context.Context, arg []UserRolesParams) (ret []UserRolesParams, errs []error)
	BulkDeleteUserRoles(ctx context.Context, arg []UserRolesParams) []error
}

Store provides all functions to execute db queries and transaction

func NewStore

func NewStore(connPool *pgxpool.Pool) Store

NewStore creates a new store

type UpdateRoleParams

type UpdateRoleParams struct {
	Name        pgtype.Text `json:"name"`
	Description pgtype.Text `json:"description"`
	ID          int64       `json:"id"`
}

type UpdateStationHealthParams

type UpdateStationHealthParams struct {
	Vb1               pgtype.Float4      `json:"vb1"`
	Vb2               pgtype.Float4      `json:"vb2"`
	Curr              pgtype.Float4      `json:"curr"`
	Bp1               pgtype.Float4      `json:"bp1"`
	Bp2               pgtype.Float4      `json:"bp2"`
	Cm                pgtype.Text        `json:"cm"`
	Ss                pgtype.Int4        `json:"ss"`
	TempArq           pgtype.Float4      `json:"temp_arq"`
	RhArq             pgtype.Float4      `json:"rh_arq"`
	Fpm               pgtype.Text        `json:"fpm"`
	ErrorMsg          pgtype.Text        `json:"error_msg"`
	Message           pgtype.Text        `json:"message"`
	DataCount         pgtype.Int4        `json:"data_count"`
	DataStatus        pgtype.Text        `json:"data_status"`
	Timestamp         pgtype.Timestamptz `json:"timestamp"`
	MinutesDifference pgtype.Int4        `json:"minutes_difference"`
	StationID         int64              `json:"station_id"`
	ID                int64              `json:"id"`
}

type UpdateStationObservationParams

type UpdateStationObservationParams struct {
	Pres      pgtype.Float4      `json:"pres"`
	Rr        pgtype.Float4      `json:"rr"`
	Rh        pgtype.Float4      `json:"rh"`
	Temp      pgtype.Float4      `json:"temp"`
	Td        pgtype.Float4      `json:"td"`
	Wdir      pgtype.Float4      `json:"wdir"`
	Wspd      pgtype.Float4      `json:"wspd"`
	Wspdx     pgtype.Float4      `json:"wspdx"`
	Srad      pgtype.Float4      `json:"srad"`
	Mslp      pgtype.Float4      `json:"mslp"`
	Hi        pgtype.Float4      `json:"hi"`
	Wchill    pgtype.Float4      `json:"wchill"`
	Timestamp pgtype.Timestamptz `json:"timestamp"`
	QcLevel   pgtype.Int4        `json:"qc_level"`
	StationID int64              `json:"station_id"`
	ID        int64              `json:"id"`
}

type UpdateStationParams

type UpdateStationParams struct {
	Name          pgtype.Text   `json:"name"`
	Lat           pgtype.Float4 `json:"lat"`
	Lon           pgtype.Float4 `json:"lon"`
	Elevation     pgtype.Float4 `json:"elevation"`
	DateInstalled pgtype.Date   `json:"date_installed"`
	MoStationID   pgtype.Text   `json:"mo_station_id"`
	SmsSystemType pgtype.Text   `json:"sms_system_type"`
	MobileNumber  pgtype.Text   `json:"mobile_number"`
	StationType   pgtype.Text   `json:"station_type"`
	StationType2  pgtype.Text   `json:"station_type2"`
	StationUrl    pgtype.Text   `json:"station_url"`
	Status        pgtype.Text   `json:"status"`
	LoggerVersion pgtype.Text   `json:"logger_version"`
	PriorityLevel pgtype.Text   `json:"priority_level"`
	ProviderID    pgtype.Text   `json:"provider_id"`
	Province      pgtype.Text   `json:"province"`
	Region        pgtype.Text   `json:"region"`
	Address       pgtype.Text   `json:"address"`
	ID            int64         `json:"id"`
}

type UpdateUserParams

type UpdateUserParams struct {
	Password          pgtype.Text        `json:"password"`
	PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
	FullName          pgtype.Text        `json:"full_name"`
	Email             pgtype.Text        `json:"email"`
	ID                int64              `json:"id"`
}

type User

type User struct {
	ID                int64              `json:"id"`
	Username          string             `json:"username"`
	FullName          string             `json:"full_name"`
	Email             string             `json:"email"`
	Password          string             `json:"password"`
	EmailVerifiedAt   pgtype.Timestamptz `json:"email_verified_at"`
	PasswordChangedAt pgtype.Timestamptz `json:"password_changed_at"`
	CreatedAt         pgtype.Timestamptz `json:"created_at"`
	UpdatedAt         pgtype.Timestamptz `json:"updated_at"`
}

type UserRolesParams

type UserRolesParams struct {
	Username string `json:"username"`
	RoleName string `json:"role_name"`
}

Jump to

Keyboard shortcuts

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