Firestore Entities (BETA)(Docs)
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.
Installation
pip install firestore-entities
Examples
"""
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)
account.put()
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"
user.put()
# Get an existing user
john = User.get(user.id)
# Query users
user2 = User.query().equal("email", "jane@doe.fam")[0]
users = User.query()
for _user in users:
print(_user.email)
Metadata
Release files for firestore-entities 0.2.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| firestore-entities-0.2.5.tar.gz | 8.1 kB | Without provenance | Details for firestore-entities-0.2.5.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| firestore_entities-0.2.5-py3-none-any.whl | Python 3 | none | any | Details for firestore_entities-0.2.5-py3-none-any.whl |
Total release size: 17.1 kB
Release files / firestore-entities-0.2.5.tar.gz
| Download URL | firestore-entities-0.2.5.tar.gz |
|---|---|
| Size | 8.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8f21d53ef731b74b2f95fd50a3163b80b3a31134df4c04324fdd3b32f0276028
|
|
BLAKE2b-256 checksum How to use checksums |
649fa936b93ab01b5ea3c6f74ca546983f6202cefd51be9b6750c554daf525de
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.1
|
Release files / firestore_entities-0.2.5-py3-none-any.whl
| Download URL | firestore_entities-0.2.5-py3-none-any.whl |
|---|---|
| Size | 9.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5404ccc4aa7806232029c3329a6069eff1838c8c87b2987898e2c1837df2e7c6
|
|
BLAKE2b-256 checksum How to use checksums |
c464c3150bc958412c0a4eb1fa7429271f4051d4cbbbcf9ea72c0a630f1ede61
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.8.1
|
Security for firestore-entities 0.2.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.