hiling_go/db/sqlc/reviews.sql.go

71 lines
1.7 KiB
Go
Raw Permalink Normal View History

// Code generated by sqlc. DO NOT EDIT.
// versions:
2024-08-19 07:40:01 +07:00
// sqlc v1.26.0
// source: reviews.sql
package db
import (
"context"
2024-02-06 11:55:25 +07:00
"github.com/jackc/pgx/v5/pgtype"
)
const checkIfReviewExists = `-- name: CheckIfReviewExists :one
SELECT COUNT(1)
FROM reviews
WHERE reviews.location_id = $1 AND reviews.submitted_by = $2
`
type CheckIfReviewExistsParams struct {
LocationID int32 `json:"location_id"`
SubmittedBy int32 `json:"submitted_by"`
}
func (q *Queries) CheckIfReviewExists(ctx context.Context, arg CheckIfReviewExistsParams) (int64, error) {
2024-02-06 11:55:25 +07:00
row := q.db.QueryRow(ctx, checkIfReviewExists, arg.LocationID, arg.SubmittedBy)
var count int64
err := row.Scan(&count)
return count, err
}
const getUserReviewByLocation = `-- name: GetUserReviewByLocation :one
SELECT
re.id,
re.location_id,
re.score,
re.comments,
re.created_at,
re.updated_at
FROM reviews re
WHERE submitted_by = $1 AND location_id = $2
`
type GetUserReviewByLocationParams struct {
SubmittedBy int32 `json:"submitted_by"`
LocationID int32 `json:"location_id"`
}
type GetUserReviewByLocationRow struct {
2024-02-06 11:55:25 +07:00
ID int32 `json:"id"`
LocationID int32 `json:"location_id"`
Score int16 `json:"score"`
Comments string `json:"comments"`
CreatedAt pgtype.Timestamp `json:"created_at"`
UpdatedAt pgtype.Timestamp `json:"updated_at"`
}
func (q *Queries) GetUserReviewByLocation(ctx context.Context, arg GetUserReviewByLocationParams) (GetUserReviewByLocationRow, error) {
2024-02-06 11:55:25 +07:00
row := q.db.QueryRow(ctx, getUserReviewByLocation, arg.SubmittedBy, arg.LocationID)
var i GetUserReviewByLocationRow
err := row.Scan(
&i.ID,
&i.LocationID,
&i.Score,
&i.Comments,
&i.CreatedAt,
&i.UpdatedAt,
)
return i, err
}