Skip to main content

Simple Firestore collection definitions and queries using pydantic schemas and Firestore query API.

Project description

Firestore Collections

Simple Firestore collection definitions and queries using pydantic schemas and Firestore query API.

A quick and easy way to make sure of the NoSQL document database solution Firestore available in Google Cloud Platform.


  • Python 3.6+


  • Schema definition and validation: Define collection schemas using pydantic and built-in type hinting (typing).
  • Automatic IDs: Automatic ID generation using 12-byte hexadecimal (bson.ObjectId).
  • Simple queries: Query collections using a simple interface.
  • Auxiliary timestamps: Automatically added timestamps to objects like created_at and updated_at.


Define users collection and perform different queries:

from typing import Optional

from pydantic import EmailStr, SecretStr
from firestore_collections import Collection, Schema

class User(Schema):
    __collection_name__ = 'users'

    email: EmailStr
    full_name: str = None
    password: Optional[SecretStr]

# Initialize firestore collection
collection = Collection(schema=User)

# Initialize user object
user = User(

# Insert
user = collection.insert(user)

# Get object from db
user = collection.get(

# Update
user.full_name = 'John Doe'

# Get by attribute
user = collection.get_by_attribute('email', '')

# Get all objects
users = collection.get_all()

# Delete object


This project is licensed under the terms of the MIT license.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firestore-collections-0.0.1.tar.gz (5.2 kB view hashes)

Uploaded Source

Built Distribution

firestore_collections-0.0.1-py3.8.egg (13.7 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page