Skip to main content

Firestore

Details:

Firestore is an offline available ORM/ODM atop Google Firestore.

Repository:

https://github.com/workenvoy/firestore

Author:

Workenvoy Inc (http://github.com/workenvoy)

Maintainer:

Raymond Ortserga (http://github.com/rayattack)

https://travis-ci.org/workenvoy/firestore.svg?branch=master https://coveralls.io/repos/github/workenvoy/firestore/badge.svg?branch=master

Details

Firestore is a Python Object-Document/Object-Collections Mapper for working with Google Firestore. The Flexible, Extremely Scalable, realtime database by Google. You can find some documentation at https://firestore.readthedocs.io - and there is also a quickstart tutorial.

Offline Support

Firestore currently uses an in-memory data store to simulate access to Google Firestore when working offline. There is an optimistic persistence to disk and the contents can be seen in the /projectdir/localfire directory. Deleting this directly means you lose all the data you might have saved prior to removing the directory from disk. Make sure to make a copy of this directory if you want to keep a copy of your data and you are encouraged to contribute i.e. open an issue, submit a pull request if you want to offer a helping hand.

Installation

We recommend the use of virtual environments e.g. virtualenv to control your package management. Installation of Firestore is easily done pip install -U firestore and requires pip. to be installed. Otherwise, you can download the source code from GitHub and run python setup.py install.

Dependencies

We tried to keep the dependencies to a minimum, and all dependencies are available using pip. The only dependencies you require to use Firestore are highlighted below:

  • google-cloud-firestore

If you are working with dates extensive we suggest you use a date parser:

  • dateutil>=2.1.0

Examples

Sample Firestore Code Snippet:

from firestore import Collection, Document, Reference as Ref
from firestore import Array
from firestore import Integer
from firestore import String
from firestore.lazy import Datatype

class SomeRootCollection(Collection):
    """
    Root collections inherit directly from collection, whilst
    sub collections will inherit from a document.

    To understand this always remember in Firestore a collection can never be
    a child of another collection, and a sub-collection will always live
    under a document.
    To have mongo style sub-collections use the Map datatype
    """
    pass


class User(SomeRootCollection):
    """
    This is the User document and will be saved under the
    collection `SomeRootCollection`.
    Documents live under collections or sub-collections directly
    """
    __private__ = ["password"]

    first_name = String(required=True)
    middle_name = Datatype(datatype="String")  # You can use Datatype in place of more specific types
    last_name = Datatype("StrInG")  # Case insensitive
    age = Integer(minimum=0)
    photos = Reference('Photo')
    password = String(minimum=6)  # private fields can not be viewed with get_XXX methods


class Photo(User):
    """
    This creates a photos subcollection under the User document for documents
    under the root collection
    """
    id = String(required=True, id=True)  # omit to have id auto-generated by cloud firestore
    photo_urls = Array()


# Create a text-based post
>>> user = User()
>>> user.first_name = "Alan"
>>> user.last_name = "Turing"
>>> user.photos.append("https://cloudinary.com/img.jpg")
>>>
>>> # this will persist user and photo at
>>> # once unlike user.save that will save only user
>>> user.persist()

# Sometimes you want one thing to succeed before doing another
>>> user.photos.safe_save()  # only saves if parent was prior saved else fails
>>> user.photos.save()  # saves regardless

# You can also save a photo by itself and query easily
>>> photo = Photo()
>>> photo.parent = user
>>> photo.save()  # save only photo
>>> photo.parent.save()

Contributing

We love contributors: Contribution guidelines

Release files for firestore 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for firestore 0.0.8
File Size Uploaded
firestore-0.0.8.tar.gz 25.5 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for firestore 0.0.8
File Interpreter ABI Platform
firestore-0.0.8-py3.7.egg Legacy Egg format - - Details
firestore-0.0.8-py3-none-any.whl Python 3 none any Details

Total release size: 158.6 kB

Release files / firestore-0.0.8.tar.gz

Download URL firestore-0.0.8.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
00003c07da7ac03b03126bb7bbcb62402f2bdaa6880241824eb8e0f05a497548
BLAKE2b-256 checksum
How to use checksums
bc092b228b59dc3162b372fe5b1a86de903cac72048bf6b337e13ad830f089a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / firestore-0.0.8-py3.7.egg

Download URL firestore-0.0.8-py3.7.egg
Size 93.1 kB
Tags Egg
SHA-256 checksum
How to use checksums
78762d2807587213cf5fd4c6653d15ef5aeeb1d8768aaed5c067597ce2db8ba2
BLAKE2b-256 checksum
How to use checksums
25e49e7340df908cbee45868449cde207f7fd68899b4d45c65cd24f4a84b0347
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release files / firestore-0.0.8-py3-none-any.whl

Download URL firestore-0.0.8-py3-none-any.whl
Size 40.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ba1b8f5fe98c2cb15c4c220878e5abf780be73880e87b889d7d5cb8b60df50c3
BLAKE2b-256 checksum
How to use checksums
f61b9cf398d40e608c9c7884afb19da8a3af69f16db35e33f5ee15d223646e95
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.2 CPython/3.7.3

Release history Release notifications | RSS feed

This release

0.0.8 This release

3 release files

0.0.7

3 release files

0.0.6

3 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page