0
I have two different tables: Entrances and Exits. Each table has columns motive and value
I am using Typescript and Typeorm, and the Controller to list both is as follows:
class SaidaController {
static listAll = async (req: Request, res: Response) => {
const saidaRepository = getRepository(Saidas);
const saidas = await saidaRepository.find({
select: ["motivo", "valor"]
});
res.send(saidas);
};
}
When I access the route /exits or /entrances, returns the following Json:
{
"motivo": "MOTIVO Teste",
"valor": "50"
}
How do I sum up all output records and all input records, and subtract the two?