This commit is contained in:
Jan Eitzinger 2025-05-25 10:49:17 +02:00
parent 6e443de84f
commit dacdd3b826
3 changed files with 39 additions and 0 deletions

25
db/query.sql Normal file
View File

@ -0,0 +1,25 @@
-- name: GetAuthor :one
SELECT * FROM authors
WHERE id = ? LIMIT 1;
-- name: ListAuthors :many
SELECT * FROM authors
ORDER BY name;
-- name: CreateAuthor :one
INSERT INTO authors (
name, bio
) VALUES (
?, ?
)
RETURNING *;
-- name: UpdateAuthor :exec
UPDATE authors
set name = ?,
bio = ?
WHERE id = ?;
-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = ?;

5
db/schema.sql Normal file
View File

@ -0,0 +1,5 @@
CREATE TABLE authors (
id INTEGER PRIMARY KEY,
name TEXT NOT NULL,
bio TEXT
);

9
sqlc.yml Normal file
View File

@ -0,0 +1,9 @@
version: "2"
sql:
- engine: "sqlite"
queries: "db/query.sql"
schema: "db/schema.sql"
gen:
go:
package: "repository"
out: "internal/repository"