Skip to main content

Implementation of entities concept on top of Google cloud firestore

Project description

Firestore Entities (BETA)(Docs)

PyPI version CircleCI codecov Known Vulnerabilities

Implementation of models concept on top of Google cloud firestore. Firestore entities try to make interaction with firestore as simple as possible for the developer.


pip install firestore-entities


This code creates a model with some possible scenarios when working with firestore.Entity

Assume a case where a user can have
- Single login
- Be in multiple projects
- Have an account in each project

from firestore import Entity, SERVER_TIMESTAMP
from firestore import db

class User(Entity):
    user_name = db.TextProperty( required=True)
    email = db.TextProperty(required=True)
    full_name = db.TextProperty(required=True)
    password = db.TextProperty(required=False)
    date_registered = db.DateTimeProperty(default=SERVER_TIMESTAMP)
    __sub_collection__ = "user_data"

class Project(Entity):
    name = db.TextProperty(required=True)
    logo = db.BlobProperty()

    def create_account(self, user, roles = None ):
        if roles is None:
            roles = ["admin"]
        account = Account(user=user, roles=roles)
        return account

class Account(Entity):
    __sub_collection__ = Project
    user = db.ReferenceProperty(User)
    roles = db.ListProperty(db.TextProperty())
    date_added = db.DateTimeProperty(auto_add_now=True)
    last_updated = db.DateTimeProperty(auto_now=True)

# Then we can
user = User(user_name="john", email="john@doe.fam", password="123456")
user.full_name = "John Doe"
# Get an existing user
john = User.get(

# Query users
user2 = User.query().equal("email", "jane@doe.fam")[0]
users = User.query()
for _user in users:

Project details

Download files

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

Files for firestore-entities, version 0.2.5
Filename, size File type Python version Upload date Hashes
Filename, size firestore_entities-0.2.5-py3-none-any.whl (9.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size firestore-entities-0.2.5.tar.gz (8.1 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page