pseudosubs-v1/srv/Admin/ED/obtenerEDs.ts

38 lines
900 B
TypeScript
Raw Permalink Normal View History

2024-02-29 13:15:31 +00:00
import {sqliteConnection as con} from "../../index";
interface RespuestaED {
ED_ID: number,
anime_ID: number,
num_ED: number,
nombre: string,
artista: string,
eps: string
}
2024-02-29 13:15:31 +00:00
export const obtenerEDs = (req: any, res: any) => {
const YAML = require('yaml');
const anime_ID: number = req.params.anime_ID;
if (anime_ID) {
const query = `SELECT * FROM ED WHERE anime_ID=${anime_ID}`;
2024-02-29 13:15:31 +00:00
con.query(query, (err, response: RespuestaED[]) => {
if (!err) {
res.send(YAML.stringify(response));
} else {
res.send("error: true");
console.log("Error al ejecutar query en /Admin/ED/nuevoED (con.query):\n" + query + "\n" + err);
}
});
} else {
res.send("error: true");
console.log("Error en /Admin/ED/obtenerEDs: anime_ID no existe.");
}
};