Skip to main content

Firestore Collections

Simple Firestore collection definitions and queries using pydantic schemas and Firestore query API.

A quick and easy way to make sure of the NoSQL document database solution Firestore available in Google Cloud Platform.

Requirements

  • Python 3.6+

Features

  • Schema definition and validation: Define collection schemas using pydantic and built-in type hinting (typing).
  • Automatic IDs: Automatic ID generation using 12-byte hexadecimal (bson.ObjectId).
  • Simple queries: Query collections using a simple interface.
  • Auxiliary timestamps: Automatically added timestamps to objects like created_at and updated_at.

Example

Define users collection and perform different queries:

from typing import Optional

from pydantic import EmailStr, SecretStr
from firestore_collections import Collection, Schema


class User(Schema):
    __collection_name__ = 'users'

    email: EmailStr
    full_name: str = None
    password: Optional[SecretStr]


# Initialize firestore collection
collection = Collection(schema=User)

# Initialize user object
user = User(
    email='john@doe.com',
    full_name='John')

# Insert
user = collection.insert(user)

# Get object from db
user = collection.get(user.id)

# Update
user.full_name = 'John Doe'
collection.update(user)

# Get by attribute
user = collection.get_by_attribute('email', 'john@doe.com')

# Get all objects
users = collection.get_all()

# Delete object
collection.delete(id=user.id)

License

This project is licensed under the terms of the MIT license.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

firestore-collections-0.0.1.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

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

firestore_collections-0.0.1-py3.8.egg (13.7 kB view details)

Uploaded Egg

File details

Details for the file firestore-collections-0.0.1.tar.gz.

File metadata

  • Download URL: firestore-collections-0.0.1.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.2

File hashes

Hashes for firestore-collections-0.0.1.tar.gz
Algorithm Hash digest
SHA256 f9744bf1fc52ce04ee65e236726373388dae89bce12fb0541554965ac35ed1e8
MD5 5e662f493d06bcecd7400a3da315593f
BLAKE2b-256 c2950017e770cd5d579080d03d27761ae000828417cc5241e6cd278f584552c2

See more details on using hashes here.

File details

Details for the file firestore_collections-0.0.1-py3.8.egg.

File metadata

  • Download URL: firestore_collections-0.0.1-py3.8.egg
  • Upload date:
  • Size: 13.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.0 CPython/3.8.2

File hashes

Hashes for firestore_collections-0.0.1-py3.8.egg
Algorithm Hash digest
SHA256 924ec254b0bae40a2ed045c399feeff5f49c3fb93885c169a1675f03b58f770f
MD5 6fd0f7e55487b7a7a3529b5b3cc8e849
BLAKE2b-256 8f61fb6efad8dfb5ae40f2ae7369bdb27c50fda2d151e3b681c179a8d43c78a2

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