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}')
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.