// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.29.0 // source: prices.sql package billing import ( "context" "database/sql" ) const createPrice = `-- name: CreatePrice :one INSERT INTO billing.prices (product_id, currency, unit_amount, recurring_interval, trial_period_days, is_active) VALUES ($1, $2, $3, $4, $5, TRUE) RETURNING price_id, product_id, currency, unit_amount, recurring_interval, trial_period_days, is_active, created_at, updated_at ` type CreatePriceParams struct { ProductID string `json:"product_id"` Currency string `json:"currency"` UnitAmount int32 `json:"unit_amount"` RecurringInterval sql.NullString `json:"recurring_interval"` TrialPeriodDays sql.NullInt32 `json:"trial_period_days"` } func (q *Queries) CreatePrice(ctx context.Context, arg CreatePriceParams) (Price, error) { row := q.db.QueryRowContext(ctx, createPrice, arg.ProductID, arg.Currency, arg.UnitAmount, arg.RecurringInterval, arg.TrialPeriodDays, ) var i Price err := row.Scan( &i.PriceID, &i.ProductID, &i.Currency, &i.UnitAmount, &i.RecurringInterval, &i.TrialPeriodDays, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const getPrice = `-- name: GetPrice :one SELECT price_id, product_id, currency, unit_amount, recurring_interval, trial_period_days, is_active, created_at, updated_at FROM billing.prices WHERE price_id = $1 ` func (q *Queries) GetPrice(ctx context.Context, priceID string) (Price, error) { row := q.db.QueryRowContext(ctx, getPrice, priceID) var i Price err := row.Scan( &i.PriceID, &i.ProductID, &i.Currency, &i.UnitAmount, &i.RecurringInterval, &i.TrialPeriodDays, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ) return i, err } const listPricesByProduct = `-- name: ListPricesByProduct :many SELECT price_id, product_id, currency, unit_amount, recurring_interval, trial_period_days, is_active, created_at, updated_at FROM billing.prices WHERE product_id = $1 AND is_active = TRUE ORDER BY created_at ASC ` func (q *Queries) ListPricesByProduct(ctx context.Context, productID string) ([]Price, error) { rows, err := q.db.QueryContext(ctx, listPricesByProduct, productID) if err != nil { return nil, err } defer rows.Close() items := []Price{} for rows.Next() { var i Price if err := rows.Scan( &i.PriceID, &i.ProductID, &i.Currency, &i.UnitAmount, &i.RecurringInterval, &i.TrialPeriodDays, &i.IsActive, &i.CreatedAt, &i.UpdatedAt, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Close(); err != nil { return nil, err } if err := rows.Err(); err != nil { return nil, err } return items, nil }