{ "info": { "author": "Benjamin Arko Afrasah", "author_email": "barkoafrasah@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Software Development :: Build Tools" ], "description": "A Firestore ORM\n===============\n\nFirestore ORM is a module that adds support for firestore Object\nRelational Mapping to your application. It requires firebase-admin\n2.16.0 or higher. It aims to simplify using Firestore collections as\nObjects by providing useful defaults and extra helpers that make it\neasier to accomplish common tasks.\n\nOverview\n========\n\nFirestore ORM provides the following key features:\n\n- Object Models - create your models in the form of python Objects.\n- Queries - perform firestore queries easily.\n- Relationships - SQL foreign key concept to join documents.\n\nUsage\n-----\n\nIn the following paragraphs, I am going to describe how you can get and\nuse Firestore ORM for your own projects.\n\nGetting it\n~~~~~~~~~~\n\nTo download Firestore ORM, either fork this github repo or simply use\nPypi via pip.\n\n.. code-block:: sh\n\n $ pip install firestore_orm\n\nCreating Models\n~~~~~~~~~~~~~~~\n\n.. code-block:: python\n\n from jsonmodels import fields\n from firestore_orm import model, relationship\n from firebase_admin import credentials\n\n cred = credentials.Certificate('path_to_service_account.json')\n\n # don't forget to initialize your firebase app\n firebase_admin.initialize_app(credential=cred, options={'storageBucket': 'storageBucket'})\n\n\n class Pet(model.Model):\n __tablename__ = 'pet'\n\n name = fields.StringField(required=True)\n\n class Person(model.Model):\n __tablename__ = 'person'\n\n name = fields.StringField(required=True)\n surname = fields.StringField(nullable=False)\n age = fields.FloatField()\n pet_id = fields.StringField(required=True)\n\n def __init__(self, **kwargs):\n super(Person, self).__init__(**kwargs)\n self.pet = relationship(self, Pet, 'pet_id')\n\nOperations\n~~~~~~~~~~\n\n.. code-block:: python\n\n\n >>> pet = Pet(name='Katty')\n >>> pet.id\n >>> '26b353d6-f5a1-4a38-b61a-b9371de5b92f'\n\n >>> pet.save() # save to firestore\n\n >>> person = Person(name='Chuck', pet_id=pet.id)\n >>> person.name\n >>> 'Chuck'\n >>> person.surname # >>> None\n\n >>> person.populate(surname='Norris', age=20)\n >>> person.surname\n >>> 'Norris'\n >>> person.name\n >>> 'Chuck'\n >>> person.id\n >>> '1286f8ae-710f-4fb7-a804-31fbed525390'\n\n >>> person.save() # save to firestore\n\n >>> Person.query.fetch()\n >>> [Person(created_at=datetime.datetime(2019, 3, 24, 13, 57, 21, 761746), name='Chuck', surname='Norris', age=20, pet_id='26b353d6-f5a1-4a38-b61a-b9371de5b92f', id='1286f8ae-710f-4fb7-a804-31fbed525390')]\n\n >>> Person.query.get('1286f8ae-710f-4fb7-a804-31fbed525390')\n >>> Person(created_at=datetime.datetime(2019, 3, 24, 13, 57, 21, 761746), name='Chuck', surname='Norris', age=20, pet_id='26b353d6-f5a1-4a38-b61a-b9371de5b92f', id='1286f8ae-710f-4fb7-a804-31fbed525390')\n\n >>> person = Person.query.get('1286f8ae-710f-4fb7-a804-31fbed525390')\n >>> person.pet\n >>> 'Pet(created_at=datetime.datetime(2019, 3, 24, 13, 57, 21, 761746), name='Katty', id='26b353d6-f5a1-4a38-b61a-b9371de5b92f')'\n\nFilter\n~~~~~~\n\nYou can filter the results of a query using the following functions\n\n.. code-block:: python\n\n >>> Person.query.fetch(filters=[('name', '==', 'Chuck'), ('age', '<=', 20)])\n >>> [Person(created_at=datetime.datetime(2019, 3, 24, 13, 57, 21, 761746), name='Chuck', surname='Norris', age=20, pet_id='26b353d6-f5a1-4a38-b61a-b9371de5b92f', id='1286f8ae-710f-4fb7-a804-31fbed525390')]\n\nOrder by\n~~~~~~~~\n\nYou can also order the results of a query. If you get an indexes error, follow the link to build the indexes on firebase\n\n.. code-block:: python\n\n >>> Person.query.fetch(order_by={\"population\": 'DESCENDING'}) # orders query by DESCENDING order: set to `ASCENDING` for ascending order\n\nAnd you are ready to go!\n\nCopyright (c) 2019 Benjamin Arko Afrasah\n\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may\nnot use this file except in compliance with the License. You may obtain\na copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.", "description_content_type": "", "docs_url": null, "download_url": "https://github.com/Silvrash/firestore-orm/releases/download/1.0.0/firestore_orm-0.0.2.tar.gz", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Silvrash/firestorm", "keywords": "ORM,firestore,firestorm_orm,firestorm", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "firestore-orm", "package_url": "https://pypi.org/project/firestore-orm/", "platform": "", "project_url": "https://pypi.org/project/firestore-orm/", "project_urls": { "Download": "https://github.com/Silvrash/firestore-orm/releases/download/1.0.0/firestore_orm-0.0.2.tar.gz", "Homepage": "https://github.com/Silvrash/firestorm" }, "release_url": "https://pypi.org/project/firestore-orm/0.0.2/", "requires_dist": null, "requires_python": "", "summary": "An ORM for firestore", "version": "0.0.2" }, "last_serial": 5976204, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "749a54f556ca6272ac42b88de115607a", "sha256": "dd0378de4afdd0f87a43f485866d9900fcbf16d04aeb6866d25b93ba29ad57e4" }, "downloads": -1, "filename": "firestore_orm-0.0.2.tar.gz", "has_sig": false, "md5_digest": "749a54f556ca6272ac42b88de115607a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6268, "upload_time": "2019-10-15T10:53:40", "url": "https://files.pythonhosted.org/packages/c1/f4/be49fd36ad36ff46d635bc20b68932c8785fa21042e88dfc55eeeacdb92d/firestore_orm-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "749a54f556ca6272ac42b88de115607a", "sha256": "dd0378de4afdd0f87a43f485866d9900fcbf16d04aeb6866d25b93ba29ad57e4" }, "downloads": -1, "filename": "firestore_orm-0.0.2.tar.gz", "has_sig": false, "md5_digest": "749a54f556ca6272ac42b88de115607a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6268, "upload_time": "2019-10-15T10:53:40", "url": "https://files.pythonhosted.org/packages/c1/f4/be49fd36ad36ff46d635bc20b68932c8785fa21042e88dfc55eeeacdb92d/firestore_orm-0.0.2.tar.gz" } ] }