// Code generated by sqlc. DO NOT EDIT. // versions: // sqlc v1.30.0 // source: empresas.sql package generated import ( "context" "github.com/jackc/pgx/v5/pgtype" ) const createEmpresa = `-- name: CreateEmpresa :one INSERT INTO empresas (nome, regiao) VALUES ($1, $2) RETURNING id, nome, criado_em, regiao ` type CreateEmpresaParams struct { Nome string `json:"nome"` Regiao pgtype.Text `json:"regiao"` } func (q *Queries) CreateEmpresa(ctx context.Context, arg CreateEmpresaParams) (Empresa, error) { row := q.db.QueryRow(ctx, createEmpresa, arg.Nome, arg.Regiao) var i Empresa err := row.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ) return i, err } const deleteEmpresa = `-- name: DeleteEmpresa :exec DELETE FROM empresas WHERE id = $1 AND regiao = $2 ` type DeleteEmpresaParams struct { ID pgtype.UUID `json:"id"` Regiao pgtype.Text `json:"regiao"` } func (q *Queries) DeleteEmpresa(ctx context.Context, arg DeleteEmpresaParams) error { _, err := q.db.Exec(ctx, deleteEmpresa, arg.ID, arg.Regiao) return err } const getEmpresaByID = `-- name: GetEmpresaByID :one SELECT id, nome, criado_em, regiao FROM empresas WHERE id = $1 AND regiao = $2 ` type GetEmpresaByIDParams struct { ID pgtype.UUID `json:"id"` Regiao pgtype.Text `json:"regiao"` } func (q *Queries) GetEmpresaByID(ctx context.Context, arg GetEmpresaByIDParams) (Empresa, error) { row := q.db.QueryRow(ctx, getEmpresaByID, arg.ID, arg.Regiao) var i Empresa err := row.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ) return i, err } const getEmpresaByIDGlobal = `-- name: GetEmpresaByIDGlobal :one SELECT id, nome, criado_em, regiao FROM empresas WHERE id = $1 ` func (q *Queries) GetEmpresaByIDGlobal(ctx context.Context, id pgtype.UUID) (Empresa, error) { row := q.db.QueryRow(ctx, getEmpresaByIDGlobal, id) var i Empresa err := row.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ) return i, err } const getEmpresaByNome = `-- name: GetEmpresaByNome :one SELECT id, nome, criado_em, regiao FROM empresas WHERE nome = $1 AND regiao = $2 ` type GetEmpresaByNomeParams struct { Nome string `json:"nome"` Regiao pgtype.Text `json:"regiao"` } func (q *Queries) GetEmpresaByNome(ctx context.Context, arg GetEmpresaByNomeParams) (Empresa, error) { row := q.db.QueryRow(ctx, getEmpresaByNome, arg.Nome, arg.Regiao) var i Empresa err := row.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ) return i, err } const listEmpresas = `-- name: ListEmpresas :many SELECT id, nome, criado_em, regiao FROM empresas WHERE regiao = $1 ORDER BY nome ` func (q *Queries) ListEmpresas(ctx context.Context, regiao pgtype.Text) ([]Empresa, error) { rows, err := q.db.Query(ctx, listEmpresas, regiao) if err != nil { return nil, err } defer rows.Close() var items []Empresa for rows.Next() { var i Empresa if err := rows.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ); err != nil { return nil, err } items = append(items, i) } if err := rows.Err(); err != nil { return nil, err } return items, nil } const updateEmpresa = `-- name: UpdateEmpresa :one UPDATE empresas SET nome = $2 WHERE id = $1 AND regiao = $3 RETURNING id, nome, criado_em, regiao ` type UpdateEmpresaParams struct { ID pgtype.UUID `json:"id"` Nome string `json:"nome"` Regiao pgtype.Text `json:"regiao"` } func (q *Queries) UpdateEmpresa(ctx context.Context, arg UpdateEmpresaParams) (Empresa, error) { row := q.db.QueryRow(ctx, updateEmpresa, arg.ID, arg.Nome, arg.Regiao) var i Empresa err := row.Scan( &i.ID, &i.Nome, &i.CriadoEm, &i.Regiao, ) return i, err }