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

511
Visualizações
Check for empty arrays in Hasura

I have the following Query:

query {
  table1(where: {table2: {id: {}}}) {
    id
  }
}

There is a relationship between table1 and table2 via a foreign key. That is, in table2 I have a column named table1_id and so I can access table2 from table1. I want to query all rows from table1 that have no related rows in table2. That is, if I do the following query:

query {
  table1 {
    table2 {
      id
    }
  }
}

I want the rows in table1 where this query returns an empty array. I have tried the following:

query {
  table1(where: {table2: {id: {_in: []}}}) {
    id
  }
}

And

query {
  table1(where: {table2: {id: {_is_null: true}}}) {
    id
  }
}

But nothing seems to work (I get back an empty array). What am I doing wrong?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

query {
  table1(where: {_not: { table2: {} } }) {
    id
  }
}

Should work to return the records from table1 that don't have a relationship with table2

over 4 years ago · Santiago Trujillo Relatório

0

The selected answer is actually incorrect. It should be the following:

query {
  table1(where: {_not: { table2: {} } }) {
    id
  }
}

Edit: The selected answer is good now :)

over 4 years ago · Santiago Trujillo Relatório
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