Skip to content

Commit

Permalink
fix: template issue
Browse files Browse the repository at this point in the history
  • Loading branch information
fbatiga committed Aug 18, 2023
1 parent 4c25096 commit 91eb48a
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/commands/generate/templates/controllers/sql.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,10 @@ class <%= entityClass %>Controller {
body: await repository
.create(data)
};
result.body = result.body.get();

if(result.body.get) {
result.body = result.body.get();
}
await execHook(modelName, 'afterApiCreate', result, { request: req, response: resp });

resp.status(200).json(result);
Expand Down Expand Up @@ -197,9 +200,11 @@ class <%= entityClass %>Controller {

const result = {
body: await repository
.create(data)
.findOne(sequelizeQuery)
};
result.body = result.body.get();
if(result.body.get) {
result.body = result.body.get();
}
await execHook(modelName, 'afterApiUpdate', result, { request: req, response: resp });

return resp.status(200).json({
Expand Down Expand Up @@ -236,7 +241,6 @@ class <%= entityClass %>Controller {
body: await repository
.destroy(sequelizeQuery)
};
result.body = result.body.get();
await execHook(modelName, 'afterApiDelete', result, { request: req, response: resp });

return resp.status(200).json(result);
Expand Down

0 comments on commit 91eb48a

Please sign in to comment.