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

193
Vistas
is there any way to find a document from firebase firestore with the query of where

I have a collection of tokens in which each document create with auto id but I store a tokenId in the document and now I want to search a single document which has specific tokenId How can I implement where query in my this code

const docRef = doc(db , "tokens")
const data= await getDoc(docRef);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

First, you should use collection() instead of doc() to create a CollectionReference. Then you can build the required Query using query() with where() as shown below:

import { collection, getDocs, query, where } from "firebase/firestore"

const colRef = collection(db , "tokens")

const qSnap = await getDocs(query(colRef, where("tokenId", "==", "TOKEN_VALUE")));

if (qSnap.size) {
  const data = qSnap.docs[0].data();
} else {
  console.log("No token found")
}

Also checkout:

  • Firestore: What's the pattern for adding new data in Web v9?
  • Perform simple and compound queries in Cloud Firestore
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