How to make a recursive model relationship in Nodejs (Adonis)?

Asked

Viewed 32 times

0

Hello, I’m having a doubt that I haven’t found anywhere yet (or didn’t know how to look). In Laravel/Cakephp I can easily relate models and make queries with models recursively.

How can I make with Adonis Js a query in my Board bring the tasks and in Tasks bring the Status?

boards: {
   name: 'Meu board',
   tasks: {
      { 
         name: 'Tarefa 1',
         status: {
            name: 'Médio'
         }
      },
      { 
         name: 'Tarefa 2',
         status: {
            name: 'Alto'
         }
      },
   }
}

Follows the models:

Model board (has several tasks)

inserir a descrição da imagem aqui

Model tasks only have one board and one status

inserir a descrição da imagem aqui

And the Model status has several tasks

inserir a descrição da imagem aqui

And in the board controller I query with.

inserir a descrição da imagem aqui

1 answer

0


It was resolved as follows...

Controller Board:

inserir a descrição da imagem aqui

and in the model task:

inserir a descrição da imagem aqui

Browser other questions tagged

You are not signed in. Login or sign up in order to post.