MongoDB的最小Python ODM
nanomongo的Python项目详细描述
nanomongo是python的最小mongodb对象文档映射器。 它并不试图成为一个功能完整的odm,但是如果您愿意的话 在python字典中使用pymongoapi,通常会发现 编写验证器和pymongo.Collectionwrappers,nanomongo 可能适合你的需要。
NanoMongo拥有完整的测试覆盖范围。
快速链接:Source (github)-Documentation (rtd)-Packages (PyPi)
0.4版:实用程序方法dbref_field_getters,BaseDocument.get_dbref 和错误修复Python23 text type compatibility
version 0.3:nanomongo现在与python2兼容(具有语法差异 定义文档时,请参阅文档)
功能
- 单格式Field定义,带有类型检查和一些常见的 选项,如required,default,auto_update
- pymongo-相同的索引定义
- 可选dot_notation
- '$set'和^{tt10}的赋值和删除(增量)跟踪$ 以及原子更新;您可以插入或更新
- '$addToSet'onDocument
- 即将到来的'$push''$pull'功能性
# rough example import pymongo from nanomongo import Field, BaseDocument, Index client = pymongo.MongoClient() class MyDoc(BaseDocument, dot_notation=True, client=client, db='dbname'): foo = Field(str) bar = Field(int, required=False) __indexes__ = [ Index('foo'), Index([('bar', 1), ('foo', -1)], unique=True), ] doc = MyDoc(foo='L33t') doc.bar = 42 doc.insert() Doc.find_one({'foo': 'L33t'})
nanomongo与python23兼容,我打算同时支持pymongo和motor 在引擎盖下透明。
欢迎您的贡献和见解!
Author: | Eren Güven (GitHub, Twitter) |
---|---|
License: | Apache Software License |