168 lines
3.9 KiB
Go
168 lines
3.9 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.29.0
|
|
// source: custom_odds.sql
|
|
|
|
package dbgen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const DeleteCustomOddByEventID = `-- name: DeleteCustomOddByEventID :exec
|
|
DELETE FROM custom_odds_market
|
|
WHERE event_id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCustomOddByEventID(ctx context.Context, eventID string) error {
|
|
_, err := q.db.Exec(ctx, DeleteCustomOddByEventID, eventID)
|
|
return err
|
|
}
|
|
|
|
const DeleteCustomOddsByID = `-- name: DeleteCustomOddsByID :exec
|
|
DELETE FROM custom_odds_market
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) DeleteCustomOddsByID(ctx context.Context, id int64) error {
|
|
_, err := q.db.Exec(ctx, DeleteCustomOddsByID, id)
|
|
return err
|
|
}
|
|
|
|
const DeleteCustomOddsByOddID = `-- name: DeleteCustomOddsByOddID :exec
|
|
DELETE FROM custom_odds_market
|
|
WHERE odds_market_id = $1
|
|
AND company_id = $2
|
|
`
|
|
|
|
type DeleteCustomOddsByOddIDParams struct {
|
|
OddsMarketID int64 `json:"odds_market_id"`
|
|
CompanyID int64 `json:"company_id"`
|
|
}
|
|
|
|
func (q *Queries) DeleteCustomOddsByOddID(ctx context.Context, arg DeleteCustomOddsByOddIDParams) error {
|
|
_, err := q.db.Exec(ctx, DeleteCustomOddsByOddID, arg.OddsMarketID, arg.CompanyID)
|
|
return err
|
|
}
|
|
|
|
const GetAllCustomOdds = `-- name: GetAllCustomOdds :many
|
|
SELECT id, company_id, odds_market_id, event_id, raw_odds, created_at
|
|
FROM custom_odds_market
|
|
WHERE (
|
|
company_id = $1
|
|
OR $1 IS NULL
|
|
)
|
|
`
|
|
|
|
func (q *Queries) GetAllCustomOdds(ctx context.Context, companyID pgtype.Int8) ([]CustomOddsMarket, error) {
|
|
rows, err := q.db.Query(ctx, GetAllCustomOdds, companyID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []CustomOddsMarket
|
|
for rows.Next() {
|
|
var i CustomOddsMarket
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CompanyID,
|
|
&i.OddsMarketID,
|
|
&i.EventID,
|
|
&i.RawOdds,
|
|
&i.CreatedAt,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const GetCustomOddByID = `-- name: GetCustomOddByID :one
|
|
SELECT id, company_id, odds_market_id, event_id, raw_odds, created_at
|
|
FROM custom_odds_market
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetCustomOddByID(ctx context.Context, id int64) (CustomOddsMarket, error) {
|
|
row := q.db.QueryRow(ctx, GetCustomOddByID, id)
|
|
var i CustomOddsMarket
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CompanyID,
|
|
&i.OddsMarketID,
|
|
&i.EventID,
|
|
&i.RawOdds,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const GetCustomOddByOddID = `-- name: GetCustomOddByOddID :one
|
|
SELECT id, company_id, odds_market_id, event_id, raw_odds, created_at
|
|
FROM custom_odds_market
|
|
WHERE odds_market_id = $1
|
|
AND company_id = $2
|
|
`
|
|
|
|
type GetCustomOddByOddIDParams struct {
|
|
OddsMarketID int64 `json:"odds_market_id"`
|
|
CompanyID int64 `json:"company_id"`
|
|
}
|
|
|
|
func (q *Queries) GetCustomOddByOddID(ctx context.Context, arg GetCustomOddByOddIDParams) (CustomOddsMarket, error) {
|
|
row := q.db.QueryRow(ctx, GetCustomOddByOddID, arg.OddsMarketID, arg.CompanyID)
|
|
var i CustomOddsMarket
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CompanyID,
|
|
&i.OddsMarketID,
|
|
&i.EventID,
|
|
&i.RawOdds,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const InsertCustomOddsMarket = `-- name: InsertCustomOddsMarket :one
|
|
INSERT INTO custom_odds_market (
|
|
odds_market_id,
|
|
company_id,
|
|
event_id,
|
|
raw_odds
|
|
)
|
|
VALUES ($1, $2, $3, $4)
|
|
RETURNING id, company_id, odds_market_id, event_id, raw_odds, created_at
|
|
`
|
|
|
|
type InsertCustomOddsMarketParams struct {
|
|
OddsMarketID int64 `json:"odds_market_id"`
|
|
CompanyID int64 `json:"company_id"`
|
|
EventID string `json:"event_id"`
|
|
RawOdds []byte `json:"raw_odds"`
|
|
}
|
|
|
|
func (q *Queries) InsertCustomOddsMarket(ctx context.Context, arg InsertCustomOddsMarketParams) (CustomOddsMarket, error) {
|
|
row := q.db.QueryRow(ctx, InsertCustomOddsMarket,
|
|
arg.OddsMarketID,
|
|
arg.CompanyID,
|
|
arg.EventID,
|
|
arg.RawOdds,
|
|
)
|
|
var i CustomOddsMarket
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CompanyID,
|
|
&i.OddsMarketID,
|
|
&i.EventID,
|
|
&i.RawOdds,
|
|
&i.CreatedAt,
|
|
)
|
|
return i, err
|
|
}
|