| CARVIEW |
hmarr / mongoengine
- Source
- Commits
- Network (16)
- Issues (13)
- Downloads (6)
- Graphs
-
Branch:
master
click here to add a description
click here to add a homepage
Pledgie Donations
Once activated, we'll place the following badge in your repository's detail box:
A Python Object-Document-Mapper for working with MongoDB — Read more
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Thu Jan 14 09:37:07 -0800 2010 | added build, dist, egg dirs to .gitignore [blackbrrr] |
| |
AUTHORS | Mon Mar 08 13:58:19 -0800 2010 | Modified AUTHORS [hmarr] |
| |
LICENSE | Sat Jan 02 13:34:48 -0800 2010 | Version bump to 0.1 beta [hmarr] |
| |
MANIFEST.in | Fri Jan 22 19:05:27 -0800 2010 | exec_js functions now acknowledge Q objects [hmarr] |
| |
README.rst | Sun Jan 03 20:34:02 -0800 2010 | Bump to v0.1.1 [hmarr] |
| |
docs/ | Mon Mar 08 14:23:40 -0800 2010 | Added rewind behaviour and BinaryField to docs [hmarr] |
| |
mongoengine/ | Mon Mar 08 14:17:21 -0800 2010 | Merge branch 'binary-fields' of git://github.co... [hmarr] |
| |
setup.py | Tue Jan 05 10:17:44 -0800 2010 | Added BooleanField [hmarr] |
| |
tests/ | Mon Mar 08 14:17:21 -0800 2010 | Merge branch 'binary-fields' of git://github.co... [hmarr] |
MongoEngine
| Info: | MongoEngine is an ORM-like layer on top of PyMongo. |
|---|---|
| Author: | Harry Marr (https://github.com/hmarr) |
About
MongoEngine is a Python Object-Document Mapper for working with MongoDB. Documentation available at https://hmarr.com/mongoengine/ - there is currently a tutorial, a user guide and an API reference.
Installation
If you have setuptools you can use easy_install mongoengine. Otherwise, you can download the source from GitHub and run python setup.py install.
Dependencies
- pymongo 1.1+
- sphinx (optional - for documentation generation)
Examples
Some simple examples of what MongoEngine code looks like:
class BlogPost(Document):
title = StringField(required=True, max_length=200)
posted = DateTimeField(default=datetime.datetime.now)
tags = ListField(StringField(max_length=50))
class TextPost(BlogPost):
content = StringField(required=True)
class LinkPost(BlogPost):
url = StringField(required=True)
# Create a text-based post
>>> post1 = TextPost(title='Using MongoEngine', content='See the tutorial')
>>> post1.tags = ['mongodb', 'mongoengine']
>>> post1.save()
# Create a link-based post
>>> post2 = LinkPost(title='MongoEngine Docs', url='hmarr.com/mongoengine')
>>> post2.tags = ['mongoengine', 'documentation']
>>> post2.save()
# Iterate over all posts using the BlogPost superclass
>>> for post in BlogPost.objects:
... print '===', post.title, '==='
... if isinstance(post, TextPost):
... print post.content
... elif isinstance(post, LinkPost):
... print 'Link:', post.url
... print
...
=== Using MongoEngine ===
See the tutorial
=== MongoEngine Docs ===
Link: hmarr.com/mongoengine
>>> len(BlogPost.objects)
2
>>> len(HtmlPost.objects)
1
>>> len(LinkPost.objects)
1
# Find tagged posts
>>> len(BlogPost.objects(tags='mongoengine'))
2
>>> len(BlogPost.objects(tags='mongodb'))
1
Tests
To run the test suite, ensure you are running a local instance of MongoDB on the standard port, and run python setup.py test.
Contributing
The source is available on GitHub - to contribute to the project, fork it on GitHub and send a pull request, all contributions and suggestions are welcome!
