use sqlc for database queries
1 file changed, 37 insertions(+), 0 deletions(-)
changed files
A query.sql
@@ -0,0 +1,37 @@ +-- name: InsertURL :execlastid +INSERT INTO url (path) VALUES (?); + +-- name: InsertFile :execlastid +INSERT INTO file (url_id, content_type, last_modified, etag, style_hash, title) +VALUES ( + @url_id, + @content_type, + @last_modified, + @etag, + @style_hash, + @title +); + +-- name: InsertContent :exec +INSERT INTO content (file_id, encoding, body) +VALUES (@fileid, @encoding, @body); + +-- name: GetFile :many +SELECT + sqlc.embed(file), + sqlc.embed(content) +FROM url +INNER JOIN file + USING (url_id) +INNER JOIN content + USING (file_id) +WHERE + url.path = ?; + +-- name: CheckPath :one +SELECT + EXISTS( + SELECT 1 + FROM url + WHERE path = ? + ) AS differs;