Mongu is yet another Python Object-Document Mapper on top of PyMongo
. It's lightweight, intuitive to use and easy to understand.
If those heavy and slow layers have nothing or more than you need, Mongu maybe the one for you.
You are the only one who knows what you reall need.
Therefor Mongu does nothing but a skeleton for you to fill.
Actually, if you have ever tried to write your own ODM, you may already implemented parts of Mongu :D
pip install mongu
- pymongo >= 2.7
Older(not ancient) version should work just fine, but 2.7 is tested.
c = Client()
@c.register_model
class User(Model):
_database_ = 'test'
_collection_ = 'users'
_defaults_ = {'is_activated': False} # default attribute
>> user = User(name='Mongu')
User({'name': 'Mongu', 'is_activated': False})
>> user.save()
User({'name': 'Mongu', 'is_activated': True, '_id': ObjectId('534f81bd7246ef6955d2388f')})
For more detailed examples and API: http://mongu.readthedocs.org
Code and documentation are available according to the MIT License.
If you thought Mongu is helpful, please tell me, a brif message like “This is what I always wanted” is enough, I would love to know!
Of course by all means feel free to send pull requests or create issues, it's always welcome and appreciated.
Thanks!