all repos — homestead @ cde569513cdb91e6f605c4240924d12f7e5d031a

Code for my website

shared/storage/sqlite/query.sql (view raw)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
-- name: InsertURL :execlastid
INSERT INTO url (path) VALUES (?);

-- name: InsertFile :execlastid
INSERT INTO file (
    url_id, content_type, last_modified, etag, style_hash, title, headers
)
VALUES (
    @url_id,
    @content_type,
    @last_modified,
    @etag,
    @style_hash,
    @title,
    @headers
);

-- 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;