aboutsummaryrefslogtreecommitdiff
path: root/src/queries.h
blob: c0bd1dc3f5b068d6fa94b77dae1dd9d41cd37820 (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
const char *q_select_entry =
"SELECT id, title, created_at::DATE, body "
"FROM entries "
"WHERE id = $1;";

const char *q_select_entries =
"SELECT id, title, created_at::DATE, body "
"FROM entries "
"ORDER BY updated_at DESC;";

const char *q_select_index =
"SELECT id, title, created_at::DATE, updated_at::DATE "
"FROM entries "
"ORDER BY updated_at DESC;";

const char *q_insert_entry =
"INSERT INTO entries "
"(title, body) "
"VALUES "
"($1, $2) "
"RETURNING id;";

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

const char *q_update_entry =
"UPDATE entries "
"SET title = $1, body = $2, updated_at = NOW() "
"WHERE id = $3 "
"RETURNING id;";

const char *q_delete_entry =
"DELETE "
"FROM entries "
"WHERE id = $1 "
"RETURNING id;";