Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

192
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!