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

797
Visualizações
How to user filter with Firestore database in React Native?

I want to filter the firestore query to get all docs that do not contain a specific value.

I used @react-native-firebase

import firestore from '@react-native-firebase/firestore';

  const getUnreadDocs = async () => {
    const unreadDocs = await firestore()
      .collection('rooms')
      .doc('aDRKtxbhG9g5IfbKcsa4')
      .collection('messages')
      .where('seen', 'not-in', ['7B6jaZngXeN7V4r3eRoDBdlcj6m2'])
      .get();

    console.log(`unreadDocs`, unreadDocs);
  };

docs return from the query

data-from-query

query-return-from-docs

How data is stored?

we have collection

rooms Collection -> Docs -> fields
         |
         V
     messages Collection -> Docs -> fields

rooms-collection-img

messages-collection-img1

messages-collection-img2

What should the query return? as we mention in query, docs should not contain 7B6jaZngXeN7V4r3eRoDBdlcj6m2 in the seen field

so, query should return only one doc i.e.

messages-collection-img1

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

The in/not-in operators checks if a current single-value field has a value that exists/does not exist in a list of values you specify. But your seen field is an array, which won't work with this operator.

Instead you'll want to use array-contains on that to check if a value is present. There is no equivalent array-does-not-contain operator to check whether a value is not present in the array field.

Also see:

  • Firestore - Possible to query by array-not-contains?
  • Firestore get documents where value not in array?
about 4 years ago · Juan Pablo Isaza 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