I am using simple Firestore
database with chats collection inside which each chat document has collection of message documents. If I want to access specific message I can do following request
msg_ref = self.db.collection('chats').document(chat_id).collection('messages').document(msg_id)
I can also access all of the messages for given chat
msgs_ref = db.collection('chats').document(chat_id).collection('messages')
for doc in msgs_ref.stream():
print(doc.id)
But I cannot understand why following command returns empty list
chat_ref = db.collection('chats').get()
And as a result this call never enters for loop
chat_ref = db.collection('chats')
for doc in chat_ref.stream():
print(doc.id)
Looking at example from official documentation
docs = db.collection(u'cities').stream()
for doc in docs:
print(f'{doc.id} => {doc.to_dict()}')
I completely don't understand what I might be doing wrong here. Can someone please explain why this is not working
chat_ref = db.collection('chats')
for doc in chat_ref.stream():
print(doc.id)
And whether I can do anything to fix it?