refactor(store): sqlc override uuid→google/uuid.UUID (убирает pgtype boilerplate)
This commit is contained in:
@@ -8,7 +8,7 @@ package db
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/jackc/pgx/v5/pgtype"
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
const createDomain = `-- name: CreateDomain :one
|
||||
@@ -18,12 +18,12 @@ RETURNING id, project_id, provider_account_id, zone_name, zone_id, template_id,
|
||||
`
|
||||
|
||||
type CreateDomainParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
ProviderAccountID pgtype.UUID `json:"provider_account_id"`
|
||||
ZoneName string `json:"zone_name"`
|
||||
ZoneID string `json:"zone_id"`
|
||||
TemplateID pgtype.UUID `json:"template_id"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
ProviderAccountID uuid.UUID `json:"provider_account_id"`
|
||||
ZoneName string `json:"zone_name"`
|
||||
ZoneID string `json:"zone_id"`
|
||||
TemplateID *uuid.UUID `json:"template_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) CreateDomain(ctx context.Context, arg CreateDomainParams) (Domain, error) {
|
||||
@@ -53,8 +53,8 @@ DELETE FROM domains WHERE id = $1 AND project_id = $2
|
||||
`
|
||||
|
||||
type DeleteDomainParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) DeleteDomain(ctx context.Context, arg DeleteDomainParams) error {
|
||||
@@ -67,8 +67,8 @@ SELECT id, project_id, provider_account_id, zone_name, zone_id, template_id, cre
|
||||
`
|
||||
|
||||
type GetDomainParams struct {
|
||||
ID pgtype.UUID `json:"id"`
|
||||
ProjectID pgtype.UUID `json:"project_id"`
|
||||
ID uuid.UUID `json:"id"`
|
||||
ProjectID uuid.UUID `json:"project_id"`
|
||||
}
|
||||
|
||||
func (q *Queries) GetDomain(ctx context.Context, arg GetDomainParams) (Domain, error) {
|
||||
@@ -90,7 +90,7 @@ const listDomains = `-- name: ListDomains :many
|
||||
SELECT id, project_id, provider_account_id, zone_name, zone_id, template_id, created_at FROM domains WHERE project_id = $1 ORDER BY created_at
|
||||
`
|
||||
|
||||
func (q *Queries) ListDomains(ctx context.Context, projectID pgtype.UUID) ([]Domain, error) {
|
||||
func (q *Queries) ListDomains(ctx context.Context, projectID uuid.UUID) ([]Domain, error) {
|
||||
rows, err := q.db.Query(ctx, listDomains, projectID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
Reference in New Issue
Block a user