firebase.firestore().collection("attendance") returns 0 result in firestore database

Viewed 2023

[Question updated]

node.js code

const updateLoggedMeetings = function () {
  return new Promise((res, rej) => {
    let query = store.collection("attendance");
    query.get()
    .then(data => {
      console.log("DATA is  ", data._size);
      }).catch(err => console.log("SOME ERROR OCCURED IN THEN BLOCK ",err));
    res(`blah`);
   })
 }

and output screenshot output

my database structure is:

1: attendance collection attendance collection

2: meetings collection meeting collection

my database query is: firebase.firestore().collection("attendance") when I run this query, it returns zero result. However when I run firebase.firestore().collection("meetings"), it returns some result. What I want to achieve is to retrieve document names of all the documents in attendance collection. Thanks

2 Answers

You are reading a collection in which all documents are marked as deleted.

In the screenshot showing your attendances, all records are displayed in italic, which means they were deleted without deleting their sub collections. In this case, the meetings_logged subcollection probably has records which are still present, BUT the attendance parent records are marked as deleted. You therefore are not able to query the attendance collection while its records are displayed in the console.

This could have happened because of a trigger set in the Cloud Functions for example.

Because attendance has nested collection again so it will not return the document. You can refer this one for better understanding. you can use like this

var attendance = 
db.collection('attendance').doc('doc_id') and you will get the logged_meeting

https://firebase.google.com/docs/firestore/data-model

Related