Skip to content

Commit

Permalink
Merge pull request #18 from fga-eps-mds/fix_return_data_language
Browse files Browse the repository at this point in the history
Fix : retorno de dados da lingua
  • Loading branch information
pedroeagle authored Oct 3, 2021
2 parents e6e00fd + d1435e0 commit 1e4cc83
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/__tests__/units/Lingua/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,20 @@ describe("\n## TESTES LINGUA\n", () => {
await modelLingua.editById({ nome: "Aikanã" }, 1);
const lingua = await modelLingua.searchById(1);
expect(lingua).toMatchObject({
id_conteudo: 3,
id_lingua: 1,
id_tronco: null,
id_conteudo: 3,
nome: "Aikanã",
tronco: null,
});
});
it("Atualizando lingua, com o metodo editById(2) na tupla de ID = 2", async () => {
await modelLingua.editById({ nome: "Aikewara" }, 2);
const lingua = await modelLingua.searchById(2);
expect(lingua).toMatchObject({
id_conteudo: 4,
id_lingua: 2,
id_tronco: null,
id_conteudo: 4,
nome: "Aikewara",
tronco: null,
});
});
});
Expand Down
13 changes: 12 additions & 1 deletion src/models/Lingua/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const LinguaModel = require("./Lingua");
const TroncoModel = require("../Tronco/Tronco");
const Conteudo = require("../Conteudo");

exports.getAll = async () => {
Expand All @@ -19,7 +20,17 @@ exports.create = async (lingua) => {
return LinguaModel.create(lingua);
};
exports.searchById = async (id) => {
return LinguaModel.findByPk(id);
return LinguaModel.findOne({
where: { id_lingua: id },
attributes: ["id_lingua", "id_conteudo", "nome"],
include: [
{
model: TroncoModel,
as: "tronco",
attributes: ["id_tronco", "nome"],
},
],
});
};
exports.searchAll = async () => {
return LinguaModel.findAll();
Expand Down

0 comments on commit 1e4cc83

Please sign in to comment.