Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

191
Visualizações
How to modify relational query strapi

Hi sorry my english is not so good. but i hope your understand. i have question about modify query in relational db. for example i have class table and student table. and relation class has many student. in each table i have a ‘status’ field. in standard strapi, it will fine. and will return like this

{
    "id": 1,
    "class_name": "A",
    "students": [{
            "id": 1,
            "name": "John Doe",
            "status": "active"
        },
        {
            "id": 2,
            "name": "Thomas A",
            "status": "inactive"
        }
    ]
}

but how to get class with status “active” student? and will return like this

{
    "id": 1,
    "class_name": "A",
    "students": [{
            "id": 1,
            "name": "John Doe",
            "status": "active"
        }
    ]
}

FYI: when i run in debug query. standard strapi will reproduce query like this.

{                                                                                                              
  method: 'select',                                                                                            
  options: {},                                                                                                 
  timeout: false,                                                                                              
  cancelOnTimeout: false,                                                                                      
  bindings: [ '1', 1 ],                                                                                        
  __knexQueryUid: 'wo9_-ifCsMpUwrldEeoFF',                                                                     
  sql: 'select "class".* from "class" where "class"."id" = ? limit ?'                                 
}                                                                                                              
{                                                                                                              
  method: 'select',                                                                                            
  options: {},                                                                                                 
  timeout: false,                                                                                              
  cancelOnTimeout: false,                                                                                      
  bindings: [ 1 ],                                                                                             
  __knexQueryUid: 'MqjWNmw_Ze4w4f4B8CyrM',                                                                     
  sql: 'select distinct "student".* from "student" where "student"."class_id" in (?)'         
} 
about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda