{ "info": { "author": "WiFast", "author_email": "rgb@wifast.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Topic :: Database" ], "description": "BearField\n=========\nA small, efficient, easy to use [MongoDB][1] object layer built on top of [PyMongo][2].\n\n[![Build Status](https://travis-ci.org/WiFast/bearfield.svg?branch=master)](https://travis-ci.org/WiFast/bearfield)\n\nFeatures\n--------\nBearField has some fun features:\n\n- Lazy field decoding. Grabbing documents is fast because BearField doesn't do anything with them\n until you do.\n- Simple field declarations: `value = Field(str)`\n- Subdocuments are easy, too: `subdoc = Field(MyDocument)`\n- All the field types: Document, date, time, datetime, list, set, dict, and all the builtins\n- Query chaining: `Q({'type': 'grizzly'}) | Q({'type': 'kodiak'})`\n- Multiple connections and databases.\n\nExamples\n--------\nAdd a new connection:\n\n from bearfield import connection\n connection.add('example', 'mongodb://localhost/example')\n\nNow create a document type associated with our example connection:\n\n from bearfield import Document, Field\n\n class Bear(Document):\n class Meta:\n connection = 'example'\n\n name = Field(str)\n type = Field(str)\n height = Field(float)\n\nYou'll notice we use a `Meta` class for document metadata. Relevant options are `connection`, which\ndefines which named connection we're storing documents in, and `collection` which defaults to the\nsnake cased document class name if it is not provided. Additional options are ignored for forward\ncompaitibility.\n\nWorking with objects of that type is easy. Let's make a 9.8ft grizzly bear:\n\n bear = Bear(name='timmy', type='grizzly', height='9.8')\n bear.save()\n\nEasy. This will set the `_id` field on our `bear` object. Now lets go searching for bears:\n\n bears = Bear.find({'type': 'grizzly'})\n for bear in bears:\n print(\"This grizzly is {}ft tall!\".format(bear.height))\n\nOr you can get just one bear:\n\n bear = Bear.find_one({'_id': bear_identifier})\n print(\"My bear is {}ft tall!\".format(bear.height))\n\nThe `find_one` method does not raise an exception if it can't find your bear. Instead it will\nreturn `None`. This is good because bears do not like exceptions.\n\nThe `update` method will only update fields that have changed on a document. This is more performant\nthan save which updates the entire document at once. So this is what happens when our bear grows\nup:\n\n bear = Bear.find_one({'_id': bear_identifier})\n bear.height = 10.3\n bear.update()\n\nThe `update` method will raise an exception if the bear object has no `_id` field.\n\nYou can perform the same operation without first retrieving the object from the database:\n\n old_bear = Bear.find_and_modify({'_id': bear_identifier}, {'height': 10.3})\n print(\"My bear used to be {}ft tall! But he's bigger now!\".format(old_bear.height))\n\nNotice that `find_and_modify` returns the old value of the object. This is important since you did\nnot have a bear to play with before calling `find_and_modify`.\n\nWhat about subdocuments? Let's define a `BearType` and redefine our `Bear` document to use it:\n\n class BearType(Document):\n name = Field(str)\n avg_height = Field(int)\n colors = Field({str})\n\n class Bear(Document):\n class Meta:\n connection = 'example'\n\n name = Field(str)\n type = Field(BearType)\n height = Field(float)\n\nWe've changed the type of our `type` field to `BearType`. The `BearType` does not require a `Meta`\nclass because it is not associated with a collection. Using it is still easy:\n\n grizzly = BearType(name='grizzly', avg_height=9.3, colors={'brown'})\n bear = Bear(name='timmy', type=grizzly, height=10.3)\n\nOn the other hand it might make more sense to keep our BearTypes in their own collection. We can\nuse references to make accessing the associated type easy. References are associated with a\ndocument model and may store an ObjectId or Query. We'll redefine our documents like this:\n\n from bearfield import Reference\n\n class BearType(Document):\n class Meta:\n connection = 'test'\n\n name = Field(str)\n avg_height = Field(int)\n colors = Field({str})\n\n class Bear(Document):\n class Meta:\n connection = 'example'\n\n name = Field(str)\n type = Reference(BearType)\n height = Field(float)\n\nCreating the bear is similar. The only difference is that the grizzly type needs to be saved in the\ndatabase before setting it on the bear document:\n\n grizzly = BearType(name='grizzly', avg_height=9.3, colors={'brown'})\n grizzly.save()\n bear = Bear(name='timmy', type=grizzly, height=10.3)\n\nReferences use find and find_one methods to retrieve the object. References are designed this way\nso that you, the user, don't anger any bears by executing queries you don't know about.\n\n type = bear.type.find_one()\n\nRemember that we can also set References to query values. We can query by name to accomplish the\nsame as above:\n\n bear.type = {'name': 'grizzly'}\n type = bear.type.find_one()\n\nSee, bears like it when things are easy.\n\nLicense\n-------\nCopyright (c) 2014 WiFast, Inc. This project and all of its contents is licensed under the\nBSD-derived license as found in the included [LICENSE][3] file.\n\n[1]: http://www.mongodb.org/ \"MongoDB\"\n[2]: http://api.mongodb.org/python/current/ \"PyMongo\"\n[3]: https://github.com/WiFast/bearfield/blob/master/LICENSE \"LICENSE\"", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/WiFast/bearfield", "keywords": "python mongodb", "license": "BSD-derived", "maintainer": null, "maintainer_email": null, "name": "bearfield", "package_url": "https://pypi.org/project/bearfield/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/bearfield/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/WiFast/bearfield" }, "release_url": "https://pypi.org/project/bearfield/1.9.6/", "requires_dist": null, "requires_python": null, "summary": "Small MongoDB object layer.", "version": "1.9.6" }, "last_serial": 1823145, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "0009c6fe99c0b56b8cd866a97feb357d", "sha256": "d6cd32c4c39a12a55b1177f35efb4a117841082e6aaf5d6d5735e89d9ec4feb1" }, "downloads": -1, "filename": "bearfield-1.0.tar.gz", "has_sig": false, "md5_digest": "0009c6fe99c0b56b8cd866a97feb357d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 20229, "upload_time": "2014-06-07T03:35:59", "url": "https://files.pythonhosted.org/packages/c8/76/17a47fb07195abd650113e2e54230f4866f103adc1ec96a174a9ad449888/bearfield-1.0.tar.gz" } ], "1.1": [ { "comment_text": "", "digests": { "md5": "583bee7301c8c25c7670ced94831d563", "sha256": "d8354c0b431a9a04d567ad31f1958907576b67a80443e4641fe6f15d0581fc7a" }, "downloads": -1, "filename": "bearfield-1.1.tar.gz", "has_sig": false, "md5_digest": "583bee7301c8c25c7670ced94831d563", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27802, "upload_time": "2014-06-12T18:12:11", "url": "https://files.pythonhosted.org/packages/5e/0a/32303641a09b8f228be1dd7a7ab0af00070f1c516550e53395f3b9374e88/bearfield-1.1.tar.gz" } ], "1.2": [ { "comment_text": "", "digests": { "md5": "7867ea41403501216186e4c4ca6b5f75", "sha256": "dc630e7954503f3d5d21ffcef398dd12abb411a4fcf4c3541e02e9c993d7e806" }, "downloads": -1, "filename": "bearfield-1.2.tar.gz", "has_sig": false, "md5_digest": "7867ea41403501216186e4c4ca6b5f75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27861, "upload_time": "2014-06-18T20:30:00", "url": "https://files.pythonhosted.org/packages/c7/92/788a4adcea70b8c540c20da2823928a56eaa1d53f6737707d32128d501d2/bearfield-1.2.tar.gz" } ], "1.3": [ { "comment_text": "", "digests": { "md5": "da97e239dd131ba9f232988249485015", "sha256": "66747adb4a2863597220f1ea5cd27ecd6df74d3e391fef388ba18ddf9f614f8b" }, "downloads": -1, "filename": "bearfield-1.3.tar.gz", "has_sig": false, "md5_digest": "da97e239dd131ba9f232988249485015", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17841, "upload_time": "2014-07-07T17:09:53", "url": "https://files.pythonhosted.org/packages/b0/1b/c4d989ff8ed7d6baacf19aed2541e2e1acf7e4b24a63ddd0cd70bed1e5e6/bearfield-1.3.tar.gz" } ], "1.4": [ { "comment_text": "", "digests": { "md5": "9cab34e1a18f1eb3a31254394d63ca0b", "sha256": "594ebc6150e9c04a00df9ff4504263943a4c1908eab6a9eaf5012a50f7f9026c" }, "downloads": -1, "filename": "bearfield-1.4.tar.gz", "has_sig": false, "md5_digest": "9cab34e1a18f1eb3a31254394d63ca0b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17991, "upload_time": "2014-07-07T18:55:56", "url": "https://files.pythonhosted.org/packages/2a/5d/0f5d2ec627977f2d67ef1e20d479a93e44a62cb17b3126c437bdc82dfb0f/bearfield-1.4.tar.gz" } ], "1.5": [ { "comment_text": "", "digests": { "md5": "ce0d75b0580424bf9ac65000519b36db", "sha256": "a912edac4fb4bdb4d2e32138bf3da6debaf7102a82f75fda9035808080c5c3b1" }, "downloads": -1, "filename": "bearfield-1.5.tar.gz", "has_sig": false, "md5_digest": "ce0d75b0580424bf9ac65000519b36db", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18070, "upload_time": "2014-07-10T16:17:36", "url": "https://files.pythonhosted.org/packages/54/6e/2174dbe07e26bd82f9744c3b869c78b70521bd3bc2c216838d0b07982590/bearfield-1.5.tar.gz" } ], "1.6": [ { "comment_text": "", "digests": { "md5": "1abb0d7a10a81d64eaa3180055ce3dab", "sha256": "f569f35b27f16bc296b1b3d346f0843efd5ba801f85fb302a5adf9d7ebd3b55c" }, "downloads": -1, "filename": "bearfield-1.6.tar.gz", "has_sig": false, "md5_digest": "1abb0d7a10a81d64eaa3180055ce3dab", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18070, "upload_time": "2014-07-10T18:47:26", "url": "https://files.pythonhosted.org/packages/5e/35/c80a3dcb53e418eeea31d67cf8a6e2f086815f9582b7061440be9c8f21ba/bearfield-1.6.tar.gz" } ], "1.7": [ { "comment_text": "", "digests": { "md5": "b1332bafed540349853568cb3d9eb000", "sha256": "bd13dc459a2d7f913a942f48b73ab77af1cddea684e2b59474c373fef30ebf30" }, "downloads": -1, "filename": "bearfield-1.7.tar.gz", "has_sig": false, "md5_digest": "b1332bafed540349853568cb3d9eb000", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18064, "upload_time": "2014-07-17T18:51:33", "url": "https://files.pythonhosted.org/packages/8a/eb/98ff9ec42dce5c08961e89d542dc7ed8093647b0af0ff7819db13daf4e8c/bearfield-1.7.tar.gz" } ], "1.8": [ { "comment_text": "", "digests": { "md5": "5e6e54173c7df2d6f6010f71a210a323", "sha256": "0ce0e6df74850ed5f9eca642a621c2880c4889828ec672088ac549dc0d8a1e33" }, "downloads": -1, "filename": "bearfield-1.8.tar.gz", "has_sig": false, "md5_digest": "5e6e54173c7df2d6f6010f71a210a323", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18044, "upload_time": "2014-07-18T23:05:33", "url": "https://files.pythonhosted.org/packages/12/7f/7f1c4d31cc8dae3185850d47c3b034c8c16bbccde719d891c0fb11f1f1dd/bearfield-1.8.tar.gz" } ], "1.9": [ { "comment_text": "", "digests": { "md5": "9b89df27893be54f7dfb23d45f6c68c1", "sha256": "c749b10761514926ccc3181c741494383a7751a420140cce897b3336fdffab9e" }, "downloads": -1, "filename": "bearfield-1.9.tar.gz", "has_sig": false, "md5_digest": "9b89df27893be54f7dfb23d45f6c68c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18315, "upload_time": "2015-02-24T22:33:42", "url": "https://files.pythonhosted.org/packages/93/bb/d98498f8387fc053448e0dc7d213ffaab0ba6071e34418f979648d2093ac/bearfield-1.9.tar.gz" } ], "1.9.1": [ { "comment_text": "", "digests": { "md5": "e4757e44f925b9bb3966924ad32d5b4e", "sha256": "e2021ce0475dbb43ffb60f426921ee9b1a04bdac825bddf2c61118b46ef9334e" }, "downloads": -1, "filename": "bearfield-1.9.1.tar.gz", "has_sig": false, "md5_digest": "e4757e44f925b9bb3966924ad32d5b4e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18361, "upload_time": "2015-04-23T23:45:00", "url": "https://files.pythonhosted.org/packages/a1/b2/ea6d6e4ab86fc4871dcc61d7e45e085075a2acd7ba75f074cb8204f38d67/bearfield-1.9.1.tar.gz" } ], "1.9.2": [ { "comment_text": "", "digests": { "md5": "cd03cf34b0435c84d78117ce20075297", "sha256": "8353cb3ff1e3fe145e209a4e6e9f4781dcdac960b0a03e52ea0fdaeb1869a7d5" }, "downloads": -1, "filename": "bearfield-1.9.2.tar.gz", "has_sig": false, "md5_digest": "cd03cf34b0435c84d78117ce20075297", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18391, "upload_time": "2015-06-11T18:17:20", "url": "https://files.pythonhosted.org/packages/9b/54/8ddfd8c1888313908277f1aadf04d3f02dd457bd8b882d0119fbaecc5068/bearfield-1.9.2.tar.gz" } ], "1.9.3": [ { "comment_text": "", "digests": { "md5": "20dc3f0175af920d2cac438638edd0bf", "sha256": "a663c48471e5da1e163fa183aa1a03e8e56f15be5390244ce07d4bb79b5d9ece" }, "downloads": -1, "filename": "bearfield-1.9.3.tar.gz", "has_sig": false, "md5_digest": "20dc3f0175af920d2cac438638edd0bf", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18403, "upload_time": "2015-07-10T22:57:45", "url": "https://files.pythonhosted.org/packages/a8/51/4865e6d4a0905834ca5230d4db6c8071eae7cd72a13ed57a7eb06f9c3946/bearfield-1.9.3.tar.gz" } ], "1.9.4": [], "1.9.5": [ { "comment_text": "", "digests": { "md5": "81657ad309e61597edc4dae81262515b", "sha256": "e60075dbb3defeceaff2072b49da70eda11cf7f9ac5c4bf19ed9bc4fe1a16b76" }, "downloads": -1, "filename": "bearfield-1.9.5.tar.gz", "has_sig": false, "md5_digest": "81657ad309e61597edc4dae81262515b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18597, "upload_time": "2015-08-13T19:59:21", "url": "https://files.pythonhosted.org/packages/07/57/19b7c9d2c4ff2d2ec13f5f5ba3f8df67f9ac5d3c54af9c7f3fcbccbc7008/bearfield-1.9.5.tar.gz" } ], "1.9.6": [ { "comment_text": "", "digests": { "md5": "1d3c14a19eccfcd7a13146086292c8e3", "sha256": "793fddc52d53e77fb7eb31066ae9a2178814ca9b7d66aa382728c83afaa552dd" }, "downloads": -1, "filename": "bearfield-1.9.6.tar.gz", "has_sig": false, "md5_digest": "1d3c14a19eccfcd7a13146086292c8e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18751, "upload_time": "2015-11-18T19:30:50", "url": "https://files.pythonhosted.org/packages/d8/77/ab134852952307f3d2008afd77e0af7b7d5d3768112aabf19f1204c5c8ea/bearfield-1.9.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1d3c14a19eccfcd7a13146086292c8e3", "sha256": "793fddc52d53e77fb7eb31066ae9a2178814ca9b7d66aa382728c83afaa552dd" }, "downloads": -1, "filename": "bearfield-1.9.6.tar.gz", "has_sig": false, "md5_digest": "1d3c14a19eccfcd7a13146086292c8e3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 18751, "upload_time": "2015-11-18T19:30:50", "url": "https://files.pythonhosted.org/packages/d8/77/ab134852952307f3d2008afd77e0af7b7d5d3768112aabf19f1204c5c8ea/bearfield-1.9.6.tar.gz" } ] }