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

98
Visualizações
Firestore query from collection if value exist in mapped array in expo

Im trying to get data from a collection where the information inside it is: owner_uid

members collection

and query my user collection if it exist there , if so to map it in array

users info  collection

is there a way to query this?

also tried to map the the "members collection" and then try to query comparing to the array with no success , is it possible? the code i tried:

 const { chh } = props.route?.params; //current house hold
  const [members, setMembers] = useState([]);
  const [chhUsers, setChhUsers] = useState([]);

  useEffect(() => {
    const q = query(collection(db, `households/${chh.title}/members/`));
    const querySnapshot = getDocs(q).then((querySnapshot) => {
      setChhUsers(querySnapshot.docs.map((doc) => doc.data()));
    });
    console.log(chhUsers);
  }, []);

  useEffect(() => {
    setTimeout(() => {
      const userdb = collection(db, `users`);
      const q = query(userdb, where("owner_uid", "==", chhUsers));
      const querySnapshot = getDocs(q).then((querySnapshot) => {
        setMembers(querySnapshot.docs.map((doc) => doc.data()));
      });
      console.log(members);
    }, 2000);
  }, []);

what i get from chhUsers:

Array [
  Object {
    "owner_uid": "4g8urzWb6RPP44ak9iPIlZidWDo2",
  },
]

but the query of console.log(members); return empty

if i change the chhUsers in const q = query(userdb, where("owner_uid", "==", chhUsers)); it return me the info

almost 4 years ago · Santiago Trujillo
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