show category route

master
Matt Huntington 3 years ago
parent ec7da80df2
commit 61f124f359

@ -82,6 +82,39 @@ int main()
return entries; return entries;
}); });
CROW_ROUTE(app, "/show-category/<int>")([](int category_id){
connect();
crow::json::wvalue entries;
ResultSet *res = stmt->executeQuery("call show_category("+to_string(category_id)+");");
int i = 0;
while (res->next()) {
int id = res->getInt("id");
string description = res->getString("description");
int seconds = res->getInt("seconds");
string comments = res->getString("comments");
string created_at = res->getString("created_at");
int category_id = res->getInt("category_id");
string category = res->getString("category");
string instrument = res->getString("instrument");
entries[i] = {
{"id", id},
{"description", description},
{"seconds", seconds},
{"comments", comments},
{"created_at", created_at},
{"category_id", category_id},
{"category", category},
{"instrument", instrument}
};
i++;
}
delete res;
return entries;
});
app.port(18080).run(); app.port(18080).run();
atexit(exiting); atexit(exiting);

Loading…
Cancel
Save