Giter VIP home page Giter VIP logo

firestore's Introduction

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. 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 Document, Reference
from firestore import Array
from firestore import Integer
from firestore import String
from firestore.lazy import Datatype

class Photo(Repository):
    photo_urls = Array()
    # this is valid as well - photo_urls = Datatype("array")

class User(Repository):
    __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


# 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

firestore's People

Contributors

tersoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.