Created a base to build on
This commit is contained in:
67
db/query.sql
Normal file
67
db/query.sql
Normal file
@@ -0,0 +1,67 @@
|
||||
-- name: GetUser :one
|
||||
SELECT * FROM users
|
||||
WHERE id = $1 LIMIT 1;
|
||||
|
||||
-- name: ListUsers :many
|
||||
SELECT * FROM users
|
||||
ORDER BY name;
|
||||
|
||||
-- name: CreateUser :one
|
||||
INSERT INTO users (
|
||||
name, bio
|
||||
) VALUES (
|
||||
$1, $2
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteUser :exec
|
||||
DELETE FROM users
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: CreatePlatform :one
|
||||
INSERT INTO platform (
|
||||
name
|
||||
) VALUES (
|
||||
$1
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: ListPlatforms :many
|
||||
SELECT * FROM platform
|
||||
ORDER BY name;
|
||||
|
||||
-- name: CreateGame :one
|
||||
INSERT INTO game (
|
||||
name, platform_id, score, release_year, finished
|
||||
) VALUES (
|
||||
$1, $2, $3, $4, $5
|
||||
)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetGame :one
|
||||
SELECT * FROM game
|
||||
WHERE id = $1 LIMIT 1;
|
||||
|
||||
-- name: ListGames :many
|
||||
SELECT * FROM game
|
||||
ORDER BY name;
|
||||
|
||||
-- name: UpdateGame :one
|
||||
UPDATE game
|
||||
SET name = $2, platform_id = $3, score = $4, release_year = $5, finished = $6
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeleteGame :exec
|
||||
DELETE FROM game
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: UpdatePlatform :one
|
||||
UPDATE platform
|
||||
SET name = $2
|
||||
WHERE id = $1
|
||||
RETURNING *;
|
||||
|
||||
-- name: DeletePlatform :exec
|
||||
DELETE FROM platform
|
||||
WHERE id = $1;
|
||||
Reference in New Issue
Block a user