// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.17.2 // source: invites.sql package database import ( "context" "go.jolheiser.com/invitea/database/sqlc" ) const countInvites = `-- name: CountInvites :one SELECT count(*) FROM invites ` func (q *Queries) CountInvites(ctx context.Context) (int64, error) { row := q.db.QueryRowContext(ctx, countInvites) var count int64 err := row.Scan(&count) return count, err } const createInvite = `-- name: CreateInvite :one INSERT INTO invites ( code, uses, total, expiration ) VALUES ( ?, ?, ?, ? ) RETURNING id, code, uses, total, expiration ` type CreateInviteParams struct { Code string Uses int64 Total int64 Expiration sqlc.Timestamp } func (q *Queries) CreateInvite(ctx context.Context, arg CreateInviteParams) (Invite, error) { row := q.db.QueryRowContext(ctx, createInvite, arg.Code, arg.Uses, arg.Total, arg.Expiration, ) var i Invite err := row.Scan( &i.ID, &i.Code, &i.Uses, &i.Total, &i.Expiration, ) return i, err } const deleteInvite = `-- name: DeleteInvite :exec DELETE FROM invites WHERE id = ? ` func (q *Queries) DeleteInvite(ctx context.Context, id int64) error { _, err := q.db.ExecContext(ctx, deleteInvite, id) return err } const getInvite = `-- name: GetInvite :one SELECT id, code, uses, total, expiration FROM invites WHERE id = ? LIMIT 1 ` func (q *Queries) GetInvite(ctx context.Context, id int64) (Invite, error) { row := q.db.QueryRowContext(ctx, getInvite, id) var i Invite err := row.Scan( &i.ID, &i.Code, &i.Uses, &i.Total, &i.Expiration, ) return i, err } const listInvites = `-- name: ListInvites :many SELECT id, code, uses, total, expiration FROM invites ORDER BY id ` func (q *Queries) ListInvites(ctx context.Context) ([]Invite, error) { rows, err := q.db.QueryContext(ctx, listInvites) if err != nil { return nil, err } defer rows.Close() var items []Invite for rows.Next() { var i Invite if err := rows.Scan( &i.ID, &i.Code, &i.Uses, &i.Total, &i.Expiration, ); 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 }