Pydantic models for Firestore
Project description
Pyrodantic
Pydantic models for Google Firestore.
Inspired by fireclass.
Installation
pip install pyrodantic
Usage
from google.cloud.firestore import Client
from pyrodantic import Document, FirestoreID
firestore_client = Client()
class TestDocument(Document):
document_id: FirestoreID = None
test_string: str
test_int: int
test_default: str = 'default'
class Firestore:
collection = 'test-collection'
doc = TestDocument(firestore_client, test_string='foo', test_int=1)
# doc == TestDocument(document_id=None, test_string='foo', test_int=1, test_default='default')
doc.create()
# doc == TestDocument(document_id='4f7be295accc473aa87844ec6f98443c', test_string='foo', test_int=1, test_default='default')
doc = TestDocument.get('4f7be295accc473aa87844ec6f98443c', firestore_client=firestore_client)
# doc == TestDocument(document_id='4f7be295accc473aa87844ec6f98443c', test_string='foo', test_int=1, test_default='default')
docs = list(TestDocument.where('test_string', '==', 'foo', firestore_client).stream())
# docs[0] == TestDocument(document_id='4f7be295accc473aa87844ec6f98443c', test_string='foo', test_int=1, test_default='default')
docs[0].delete()
doc = TestDocument.get('4f7be295accc473aa87844ec6f98443c', firestore_client=firestore_client)
# doc == None
TODO
- Support transactions
- Support sub-collections
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
pyrodantic-0.0.6.tar.gz
(3.7 kB
view hashes)
Built Distribution
Close
Hashes for pyrodantic-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77d259066df74c0cb6b5cd969c3e8ed103fb4b5393cd3a487744f200c49864ff |
|
MD5 | 3c7ea0074a111552a6d714dd8383550a |
|
BLAKE2b-256 | 64dc7dd9e682521e06cd6c54842709180e7b4da3f30a1b76b0eedca03bdad377 |