Skip to main content

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.7.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrodantic-0.0.7-py3-none-any.whl (4.8 kB view details)

Uploaded Python 3

File details

Details for the file pyrodantic-0.0.7.tar.gz.

File metadata

  • Download URL: pyrodantic-0.0.7.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

File hashes

Hashes for pyrodantic-0.0.7.tar.gz
Algorithm Hash digest
SHA256 247bb4f2531d26ecaa03ad12dac70ac04881ebb56f840d29addabc5486d62a6e
MD5 9445bf745b77b2bdc04f5f345cc5f23e
BLAKE2b-256 b335c2b3db94ac451ce1162f39dbae50a91b59fb4414c52b3065df4d1cf0af19

See more details on using hashes here.

File details

Details for the file pyrodantic-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: pyrodantic-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 4.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.8.2

File hashes

Hashes for pyrodantic-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 576372d6362136136634b91ca1c71e1b2498a45b8d1de64c04b19d194df1c6c2
MD5 67787e9b3ad6c45ac8f0ee2b8061561e
BLAKE2b-256 c5674727181f9fccf5418a36a5b04f5286e8eff76d0ab2eb843c309684417098

See more details on using hashes here.

Supported by

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