Files
lincodex/backend/internal/adapter/secondary/postgres/sqlc/holdings.sql.go
T

54 lines
1.4 KiB
Go

// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.31.1
// source: holdings.sql
package sqlc
import (
"context"
"github.com/jackc/pgx/v5/pgtype"
)
const getHoldingIDByFounder = `-- name: GetHoldingIDByFounder :one
SELECT id
FROM holdings
WHERE founder_account_id = $1
`
func (q *Queries) GetHoldingIDByFounder(ctx context.Context, founderAccountID pgtype.UUID) (pgtype.UUID, error) {
row := q.db.QueryRow(ctx, getHoldingIDByFounder, founderAccountID)
var id pgtype.UUID
err := row.Scan(&id)
return id, err
}
const insertHoldingIfAbsent = `-- name: InsertHoldingIfAbsent :exec
INSERT INTO holdings (
id,
founder_account_id,
created_at
) VALUES (
$1,
$2,
$3
)
ON CONFLICT (founder_account_id) DO NOTHING
`
type InsertHoldingIfAbsentParams struct {
ID pgtype.UUID
FounderAccountID pgtype.UUID
CreatedAt pgtype.Timestamptz
}
// Stores the holding of a founder account unless the account already has one.
// A concurrent creation of the same account waits on the founder key until the
// other transaction ends; then this insert does nothing, and the caller reads
// the stored holding with GetHoldingIDByFounder.
func (q *Queries) InsertHoldingIfAbsent(ctx context.Context, arg InsertHoldingIfAbsentParams) error {
_, err := q.db.Exec(ctx, insertHoldingIfAbsent, arg.ID, arg.FounderAccountID, arg.CreatedAt)
return err
}