2019-05-02 22:04:06 +00:00
|
|
|
import {con} from "../index"
|
2019-03-30 23:39:49 +00:00
|
|
|
import YAML from "yaml"
|
|
|
|
|
|
|
|
export default (req, res) ->
|
2019-05-02 22:04:06 +00:00
|
|
|
if req.params.id?
|
|
|
|
idAnime = req.params.id
|
2019-03-30 23:39:49 +00:00
|
|
|
|
2019-05-02 22:04:06 +00:00
|
|
|
query = "SELECT * FROM animes WHERE anime_ID=?"
|
2019-03-30 23:39:49 +00:00
|
|
|
|
2019-05-02 22:04:06 +00:00
|
|
|
con.query query, [idAnime], (err, respuesta) ->
|
|
|
|
res.send do ->
|
|
|
|
unless err
|
|
|
|
YAML.stringify
|
|
|
|
exito: true
|
|
|
|
payload: respuesta[0]
|
|
|
|
error: {}
|
|
|
|
else
|
|
|
|
"""
|
2019-03-30 23:39:49 +00:00
|
|
|
exito: false
|
|
|
|
payload: {}
|
|
|
|
error:
|
|
|
|
razon: "Error al ejecutar consulta en la base de datos."
|
|
|
|
ruta: "/Anime/obtenerTodosAnimes"
|
|
|
|
adicional: "Query: #{query}\nError:#{err}"
|
|
|
|
"""
|
|
|
|
|
2019-05-02 22:04:06 +00:00
|
|
|
else
|
|
|
|
res.send """
|
2019-03-30 23:39:49 +00:00
|
|
|
exito: false
|
|
|
|
payload: {}
|
|
|
|
error:
|
|
|
|
razon: "No se ha pasado ningún id."
|
|
|
|
ruta: "/Anime/obtenerTodosAnimes"
|
|
|
|
adicional: "Anime ID actual: #{req.params.id}"
|
2019-04-17 21:44:08 +00:00
|
|
|
"""
|