0
I’m learning to work with Adonisjs and I found several ways to update, but I always like the most performative way, after reading several articles and the documentation came to the following code:
async update ({ params, request }) {
const dados_aluno = request.only(['nome','cpf','dt_nascimento','peso',
'altura','sexo_id','tipo_sanguineo_id'])
const dados_endereco = request.only(['cep','endereco','numero','bairro','cidade','uf'])
const dados_contato = request.only(['email','telefone','celular'])
await Database.table('alunos').where('id', params.id).update(dados_aluno)
await Database.table('enderecos').where('aluno_id', params.id).update(dados_endereco)
await Database.table('contatoes').where('aluno_id', params.id).update(dados_contato)
}
It works, but I would like to make the three updates with a await only, it is possible?
Yes there is a relationship and I managed to do in a single await o select all e create but the update I haven’t found yet, but I will continue studying the framework because it is beautiful. I really don’t know so much about Promises and I’ll study more about them, thanks for the answer.
– Paulo Henrique N matos