diff options
Diffstat (limited to 'src/queries.h')
-rw-r--r-- | src/queries.h | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/queries.h b/src/queries.h index 696d42a..7b5b55d 100644 --- a/src/queries.h +++ b/src/queries.h @@ -6,18 +6,20 @@ const char *q_select_entry = 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;"; +"ORDER BY updated_at DESC, created_at DESC " +"LIMIT $1;"; const char *q_search_entries = -"WITH query AS " +"WITH search_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 " +" LIMIT $3 " ") " -"SELECT id, title, created_at::DATE, updated_at::DATE, body FROM query;"; +"SELECT id, title, created_at::DATE, updated_at::DATE, body FROM search_query;"; const char *q_insert_entry = "INSERT INTO entries (title, body, search_vector) " @@ -30,8 +32,8 @@ const char *q_update_entry = "WHERE id = $4 " "RETURNING id;"; -// const char *q_delete_entry = -// "DELETE " -// "FROM entries " -// "WHERE id = $1 " -// "RETURNING id;"; +const char *q_delete_entry = +"DELETE " +"FROM entries " +"WHERE id = $1 " +"RETURNING id;"; |