Getting Data
Table of contents
- Single Document
- Multiple documents
- All Documents
- Sub Collection
- Get Root collections
- Get Sub collections
Read documents from Google’s Firestore
Single Document
Read single document from collection
Example Usage
u = User.collection.get(user_key)
print(u.name)
print(u.key)
Convert model into dict
u = User.collection.get(user_key)
print(u.to_dict())
Multiple documents
Read multiple documents by providing key list
User.collection.get_all(key_list)
All Documents
Read all documents from collection
Example Usage
user_list = User.collection.fetch()
for user in user_list:
print(user.id, user.name)
Sub Collection
Get child documents from collection
Example Usage
users = User.collection.parent(parent_key).fetch()
for user in users:
print(user.id, user.name)
Get Root collections
FireO allow you to get all root collections
fireo.list_collections()
Get Sub collections
You can get subcollection
of any document
post = Post.collection.get(post_key)
post.list_subcollections()