0

The following code returns skills field from GOOGL103 document only.

However I want to get skills field from all the documents in job collection, how do I do that?

import firebase_admin
from firebase_admin import credentials,firestore

cred = credentials.Certificate("service_key.json")
firebase_admin.initialize_app(cred)

job_keywords = firestore.client().collection(u'job').document('GOOGL103').get().to_dict()['skills']

print(f'Skills Required: {job_keywords}')
Prajwol
  • 31
  • 5

1 Answers1

0

You could just query the collection and loop all the documents to get the specific fields. Check the code i wrote below:

docs = db.collection(u'job').stream()

for doc in docs:
    skills = u'{}'.format(doc.to_dict()['skills'])
    print(skills)

There are more sample snippets on Firestore documentation that you can use for your other use-cases. You may refer here for more information.

Marc Anthony B
  • 3,635
  • 2
  • 4
  • 19