in Education by
I'm querying a collection for a specific document and trying to get the document-ID from the result of my query that is from type FirebaseFirestore.QuerySnapshot. My actual query looks like this (I'm using async/await): result = await db.collection("chatrooms").where("userA", "==", req.body.userA) .where("userB", "==", req.body.userB).limit(1).get(); I tried with: await result.docs.map(doc => { return doc.id }) But that gives me an undefined back. What am I doing wrong? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
A QuerySnapshot contains zero or more DocumentSnapshot objects representing the results of a query. The documents can be accessed as an array via the docs property or enumerated using the forEach method. The number of documents can be determined via the empty and size properties. So it's going to return an array (QuerySnapshot) of QueryDocumentSnapshots. You need to loop over the snapshots using forEach() then you can get the document ID from each QueryDocumentSnapshot https://firebase.google.com/docs/reference/js/firebase.firestore.QueryDocumentSnapshot If you're using typescript, you should be able to see the definitions, methods, and properties in your IDE.

Related questions

0 votes
    this is my first question here, i hope you can help me. I've been trying to get a specific path ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    this is my first question here, i hope you can help me. I've been trying to get a specific path ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 16, 2022 in Education by JackTerrance
0 votes
    How can I find out the instance id of an ec2 instance from within the ec2 instance? Select the correct answer from above options...
asked Jan 31, 2022 in Education by JackTerrance
0 votes
    Which of the following tool is used to generate API documentation in HTML format from doc comments in ... stackoverflow.com 🔗Source: Java Interview Questions and Answers...
asked Dec 19, 2020 in Technology by Editorial Staff
0 votes
    I'm using Semantic-UI-React in my React/Rails project and trying to use a Form.Select drop down ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    I'm using Semantic-UI-React in my React/Rails project and trying to use a Form.Select drop down ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I tried to find out how to use firestore local emulator for python and for testing purpose. But I ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I am working on ajax module for Shopping cart in Magento. Consider i have a configurable product with 2 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Can we get the Tenant ID of the azure active directory without using powershell command? These two blogs helped ... -for-powershell/ Select the correct answer from above options...
asked Jan 20, 2022 in Education by JackTerrance
0 votes
    Convert a .doc or .pdf to an image and display a thumbnail in Ruby? Does anyone know how to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Convert a .doc or .pdf to an image and display a thumbnail in Ruby? Does anyone know how to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 25, 2022 in Education by JackTerrance
0 votes
    Convert a .doc or .pdf to an image and display a thumbnail in Ruby? Does anyone know how to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    extension. (e) Flash saves a file with.fla extension and executes it with (i) .fla (ii) .swf (iii) Doc (iv) fsh Select the correct answer from above options...
asked Dec 1, 2021 in Education by JackTerrance
0 votes
    I have this operation EventModel data = EventModel(_nameEvent, _passEvent, _localEvent, _dateEventString); HashMap ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
0 votes
    In Firestore documentation said: There are no additional costs for using cursors, page tokens, and limits. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 13, 2022 in Education by JackTerrance
...