Getting Data

Table of contents

  1. Single Document
  2. Multiple documents
  3. All Documents
  4. Sub Collection
  5. Get Root collections
  6. 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()