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

131
Vistas
How do I access another user's data by a specific field?

I'm trying to make a user send their num to another user. I created a random keycode for every user to send each other a num.

I tried accessing the data by querying them.

     const sendNum = async(e) => {
        const userCol = collection(db, "users")  
        e.preventDefault();
        

        const targetQuery = query(userCol, where("keycode", "==", target))
        const targetSnapshot = await getDocs(targetQuery)
        
        targetSnapshot.forEach((doc) => {
            console.log(doc.data().num);
        })
        console.log(targetSnapshot);

But it returns an object rather than the another user's num field

Nu {_firestore: xc, _userDataWriter: ah, _snapshot: Oo, metadata: Su, query: Ic}

Here's what the data looks like:

enter image description here

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

Posting the solution suggested by Doug Stevenson as a Community Wiki for visibility.

From the description it's not possible to tell what value the target holds. In this case, hard coding the value worked to access the user field.

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