const char *q_select_entry = "SELECT id, title, created_at::DATE, updated_at::DATE, body " "FROM entries " "WHERE id = $1;"; const char *q_select_entries = "SELECT id, title, created_at::DATE, updated_at::DATE, body " "FROM entries " "ORDER BY updated_at DESC, created_at DESC;"; const char *q_search_entries = "WITH query AS " "( " " SELECT id, title, created_at::DATE, updated_at::DATE, body, " " TS_RANK(search_vector, TO_TSQUERY('english', $1)) AS rank " " FROM entries " " WHERE search_vector @@ TO_TSQUERY('english', $2) " " ORDER BY rank DESC " ") " "SELECT id, title, created_at::DATE, updated_at::DATE, body FROM query;"; const char *q_update_entry = "UPDATE entries " "SET title = $1, body = $2, updated_at = NOW(), search_vector = TO_TSVECTOR('english', $3) " "WHERE id = $4 " "RETURNING id;"; // const char *q_delete_entry = // "DELETE " // "FROM entries " // "WHERE id = $1 " // "RETURNING id;";