From fc055b93be95ce6041c11ef05adc67632cf94da7 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Wed, 28 Aug 2024 11:29:20 -0400 Subject: [PATCH] instruments route --- server.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/server.cpp b/server.cpp index ddcf5d8..35e3ada 100644 --- a/server.cpp +++ b/server.cpp @@ -91,6 +91,24 @@ int main() return entries; }); + CROW_ROUTE(app, "/instruments")([](){ + connect(); + crow::json::wvalue entries; + + ResultSet *res = stmt->executeQuery("SELECT * FROM instruments"); + + int i = 0; + while (res->next()) { + int id = res->getInt("id"); + string instrument = res->getString("name"); + entries[i] = {{"id", id}, {"instrument", instrument}}; + i++; + } + + delete res; + return entries; + }); + CROW_ROUTE(app, "/categories")([](){ connect(); crow::json::wvalue entries;