-- name: GetProduct :one
SELECT * FROM products
WHERE codigo = $1 LIMIT 1;

-- name: ListProducts :many
SELECT * FROM products
ORDER BY created_at;

-- name: CreateProduct :one
INSERT INTO products (
  created_at, created_by, updated_at, updated_by, nome, codigo, estoque_total, estoque_corte, estoque_disponivel, preco_de, preco_por
) VALUES (
  $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
)
RETURNING *;

-- name: UpdateProduct :exec
UPDATE products
SET 
	updated_at = $2,
	updated_by = $3,
	nome = $4,
	estoque_total = $5,
	estoque_corte = $6,
	estoque_disponivel = $7,
	preco_de = $8,
	preco_por = $9
WHERE codigo = $1;

-- name: DeleteProduct :exec
DELETE FROM products
WHERE codigo = $1;
