1

Is there a way where i can check if there is at least 1 or more document in a collection in python?

I've tried this, it works if there is a document but if it does not have any document the loop doesn't run at all which makes sense cause there isn't any document to be loop through.

currentGame = db.collection(u'currentGame').stream()
try:
    for doc in currentGame:
        if doc.exists:
            print("exists")
        else:
            print("no document")

except google.cloud.exceptions.NotFound:
    print("not found")
Draven
  • 7
  • 5

0 Answers0