Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

795
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda