diff options
author | Michael McVady <femtonaut@gmail.com> | 2023-01-02 20:11:22 -0600 |
---|---|---|
committer | Michael McVady <femtonaut@gmail.com> | 2023-01-03 10:54:24 -0600 |
commit | 03eafcbb94df67484e80480f30660022e7142608 (patch) | |
tree | 7829053df43b34d62d2ba5ab1dfd9e3b4916b040 /src/queries.h | |
parent | 1ed181620d489d860bda150acba05d884fec147e (diff) |
Clean up query logic
Diffstat (limited to 'src/queries.h')
-rw-r--r-- | src/queries.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/queries.h b/src/queries.h new file mode 100644 index 0000000..cae7d59 --- /dev/null +++ b/src/queries.h @@ -0,0 +1,23 @@ +const char *query_html_post = \ +"SELECT id, title, created_at::DATE, body " +"FROM posts " +"WHERE id = $1;"; + +const char *query_html_posts = \ +"SELECT id, title, created_at::DATE, body " +"FROM posts " +"ORDER BY updated_at DESC;"; + +const char *query_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 *query_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;"; |