improve query necessary
This commit is contained in:
16
src/index.ts
16
src/index.ts
@@ -29,19 +29,9 @@ app.get("/api/v1/ext/query_all", (c) => {
|
||||
});
|
||||
|
||||
app.get("/api/v1/ext/query_necessary", (c) => {
|
||||
// Python code fetches all columns then filters via Pydantic model.
|
||||
// We can select just what we need or select all and map.
|
||||
// Let's select all to be consistent with the 'all()' behavior if logic changes,
|
||||
// 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);
|
||||
const query = db.query("SELECT ID, SAFE FROM extensions");
|
||||
const extensions = query.all() as ExtensionNecessary[];
|
||||
return c.json(extensions);
|
||||
});
|
||||
|
||||
app.post("/api/v1/ext/add_one", async (c) => {
|
||||
|
||||
Reference in New Issue
Block a user