Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create company endpoints #315

Merged
merged 14 commits into from
Jan 1, 2025
41 changes: 41 additions & 0 deletions backend/.sqlc/queries/companies.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
-- name: CreateCompany :one
INSERT INTO companies (
owner_id,
name,
wallet_address,
linkedin_url
) VALUES (
$1, $2, $3, $4
)
RETURNING *;

-- name: GetCompanyByID :one
SELECT * FROM companies
WHERE id = $1;

-- name: GetCompanyByOwnerID :one
SELECT * FROM companies
WHERE owner_id = $1;

-- name: UpdateCompany :one
UPDATE companies
SET
name = COALESCE($2, name),
wallet_address = COALESCE($3, wallet_address),
linkedin_url = COALESCE($4, linkedin_url),
updated_at = extract(epoch from now())
WHERE id = $1
RETURNING *;

-- name: DeleteCompany :exec
DELETE FROM companies
WHERE id = $1;

-- name: ListCompanies :many
SELECT * FROM companies
WHERE owner_id = $1
ORDER BY created_at DESC;

-- name: GetCompanyWithAuth :one
SELECT * FROM companies
WHERE (owner_id = $1 OR $2 = 'admin') AND id = $3;
197 changes: 197 additions & 0 deletions backend/db/companies.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading