A wrapper for creating model classes using Google's Cloud Firestore schemaless database
Project description
firestore-model
Quickly and simply create model classes for Google's Cloud Firestore schemaless database.
Overview
This project seeks to provide a similar convenience and utility for using Cloud Firestore with the newly available Python 3.7 App Engine Envinronment as the NDB client library does for using Cloud Datastore with Python 2.7 App Engine.
Blog post describing motivation and further usage
Example
import firestore_model
from google.firestore import firestore
from filestore_model import Model, Query
# initialize the database connection globally for Firestore Model
firestore_model.db = firestore.Client()
# Define a data structure for a User
@dataclass
class User(Model):
first_name:str
last_name:str
occupation:str
# Create a new user, pass save = True to automagically save the model object
u1 = User.make(
first_name='Sonic',
last_name='Brown',
occupation='circus dog'
save=True
)
# Fetch all users that match a given query
users = User.query([
('occupation', 'circus dog'),
('created', '>', 1540776978)
]
).get()
# Iterate through the results of the query
for u in users:
print(u.id, u.created, u.first_name, u.last_name, u.occupation)
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_model-0.0.5.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file firestore_model-0.0.5.tar.gz
.
File metadata
- Download URL: firestore_model-0.0.5.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4b3b3094347584875e17a946ce0ec00f3e7d893261987c3e928392dc5b34741 |
|
MD5 | 3f03b77f45f4318d874fa5c179d6f4ce |
|
BLAKE2b-256 | 99f17f6eeddb70f28b348c47826fcb47c843798664edebb6e2e228c59c5c1423 |
File details
Details for the file firestore_model-0.0.5-py3-none-any.whl
.
File metadata
- Download URL: firestore_model-0.0.5-py3-none-any.whl
- Upload date:
- Size: 16.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.9.1 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13ad9231997055ff257ef8516c4be559c94d1f4107b8004d45d857112b47c26f |
|
MD5 | 89ae26073ca6a15f206a41c7d36db9ab |
|
BLAKE2b-256 | 08592d8ae9b1c7714c0fee9dcf3f7b877f8b59b2c534ef53b6a1807ac9d208ba |