aboutsummaryrefslogtreecommitdiff
path: root/src/queries.h
blob: 809d259991fc6e8ca558a0d3b5cfd4a9e90a8ec0 (plain)
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
41
42
43
44
const char *q_select_html_post = \
"SELECT id, title, created_at::DATE, body "
"FROM posts "
"WHERE id = $1;";

const char *q_select_html_posts = \
"SELECT id, title, created_at::DATE, body "
"FROM posts "
"ORDER BY updated_at DESC;";

const char *q_select_json_post = \
"SELECT JSON_AGG(ROW_TO_JSON(row)) FROM ("
	"SELECT id, title, body, created_at, updated_at "
	"FROM posts "
	"WHERE id = $1"
") row;";

const char *q_select_json_posts = \
"SELECT JSON_AGG(ROW_TO_JSON(row)) FROM ("
	"SELECT id, title, body, created_at, updated_at "
	"FROM posts "
	"ORDER BY updated_at DESC"
") row;";

const char *q_insert_posts = \
"INSERT INTO posts "
"(title, body) "
"VALUES "
"($1, $2) "
"RETURNING id;";

const char *q_insert_posts_with_id = \
"INSERT INTO posts "
"(id, title, body) "
"VALUES "
"($1, $2, $3) "
"RETURNING id;";

const char *q_delete_posts = \
"DELETE "
"FROM posts "
"WHERE id = $1 "
"RETURNING id;";