Skip to main content

Firestore with Pydantic models integration

Project description

Frantic

Firestore with Pydantic models integration.

Please note that this module is a work in progress. API may change over time. Also, the code is not tested yet and there are no security checks run periodically.

Installation

Using pip

pip install frantic

Using poetry

poetry add frantic

Basic usage

If you have your service account key path set in GOOGLE_APPLICATION_CREDENTIALS, it's fairly easy:

import asyncio
from typing import ClassVar
from frantic import Frantic, BaseModel


# Create a model the same way you would do it with Pydantic
class User(BaseModel):
    # optionally, you may specify name of collection instances will be stored within:
    collection: ClassVar = "my_users_collection"
    # field 'id' is added automatically
    name: str


async def main():
    frantic = Frantic()

    user = User(name="ijustfarted")

    # Save user in the Firestore db
    await frantic.add(user)

    # user's id gets automatically populated and can be used to retrieve the user
    retrieved = await frantic.get(User, user.id)
    assert retrieved.name == user.name

    # list all users
    users = await frantic.list(User)

    # delete user
    await frantic.delete(user)
    # or
    await frantic.delete(User, user.id)

if __name__ == "__main__":
    asyncio.run(main)

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

frantic-0.1.3.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

frantic-0.1.3-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file frantic-0.1.3.tar.gz.

File metadata

  • Download URL: frantic-0.1.3.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.0 Linux/5.15.0-56-generic

File hashes

Hashes for frantic-0.1.3.tar.gz
Algorithm Hash digest
SHA256 787d8a544fc28f6b80b4e55bdc8f8fe57c2ecadc0d1b9b24afa1f78bf2892d30
MD5 813112f3a47d660bc5e7899366d3c8f2
BLAKE2b-256 f263538e45e8958cf7d8af2a390b5416cee31cba53ad2e69d10c80706413d1c4

See more details on using hashes here.

File details

Details for the file frantic-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: frantic-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.12 CPython/3.10.0 Linux/5.15.0-56-generic

File hashes

Hashes for frantic-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 00dc2ce1898a146c1d2fa2c9ef0bb95816fa2897b0c1cf0844205d990fe5f871
MD5 662953e4df2a77534931c8f72c0c984e
BLAKE2b-256 98b86c1666269d00e8a22976b250ed4c2b368576ca270afd5512e5d44eca8198

See more details on using hashes here.

Supported by

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