improve query necessary

This commit is contained in:
Julian Freeman
2025-12-01 13:37:12 -04:00
parent 2a8c121af7
commit cdef996ce8

View File

@@ -29,19 +29,9 @@ app.get("/api/v1/ext/query_all", (c) => {
}); });
app.get("/api/v1/ext/query_necessary", (c) => { app.get("/api/v1/ext/query_necessary", (c) => {
// Python code fetches all columns then filters via Pydantic model. const query = db.query("SELECT ID, SAFE FROM extensions");
// We can select just what we need or select all and map. const extensions = query.all() as ExtensionNecessary[];
// Let's select all to be consistent with the 'all()' behavior if logic changes, return c.json(extensions);
// but map to the response shape to respect the 'response_model'.
const query = db.query("SELECT * FROM extensions");
const extensions = query.all() as ExtensionInDB[];
const necessary: ExtensionNecessary[] = extensions.map((ext) => ({
ID: ext.ID,
SAFE: ext.SAFE,
}));
return c.json(necessary);
}); });
app.post("/api/v1/ext/add_one", async (c) => { app.post("/api/v1/ext/add_one", async (c) => {