V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
Livid
V2EX  ›  Python

PyMODM

  •  
  •   Livid · 2017-09-11 13:42:34 +08:00 · 4652 次点击
    这是一个创建于 2391 天前的主题,其中的信息可能已经有所发展或是发生改变。
    一个由 MongoDB 官方开发者维护的 MongoDB Python ORM 库:

    https://pypi.python.org/pypi/pymodm
    15 条回复    2017-09-11 22:00:29 +08:00
    chaleaoch
        1
    chaleaoch  
       2017-09-11 13:48:28 +08:00
    沙发,是 orm 库吗?还是类似 pymysql 的这种。
    Sanko
        2
    Sanko  
       2017-09-11 13:59:16 +08:00 via Android
    和 django 一样,赞
    Itanium
        3
    Itanium  
       2017-09-11 14:18:20 +08:00
    应该说是 ODM
    polaris1119
        4
    polaris1119  
       2017-09-11 14:21:04 +08:00
    @chaleaoch 写的很清楚 MongoDB Python ORM 库
    dcalsky
        5
    dcalsky  
       2017-09-11 14:32:31 +08:00
    又多了一条裤子
    CoderGeek
        6
    CoderGeek  
       2017-09-11 14:33:38 +08:00
    可以~
    yanzixuan
        7
    yanzixuan  
       2017-09-11 14:46:20 +08:00
    虽然不是 ORM,但是其他的 mongo model lib 可以创建关系的。比如 mongoengine, 有 ReferenceField。
    不知道这个可不可以,看了下,没有能添加关系的例子。
    yanzixuan
        8
    yanzixuan  
       2017-09-11 14:50:43 +08:00   ❤️ 1
    我在这里找到了添加关联关系的例子 http://docs.mongoengine.org/tutorial.html#defining-our-documents:

    from pymodm import EmbeddedMongoModel, MongoModel, fields

    class Comment(EmbeddedMongoModel):
    author = fields.ReferenceField(User)
    content = fields.CharField()

    class Post(MongoModel):
    title = fields.CharField()
    author = fields.ReferenceField(User)
    revised_on = fields.DateTimeField()
    content = fields.CharField()
    comments = fields.EmbeddedDocumentListField(Comment)
    doubleflower
        9
    doubleflower  
       2017-09-11 14:53:08 +08:00
    @yanzixuan 你什么眼神
    qsnow6
        10
    qsnow6  
       2017-09-11 17:39:17 +08:00
    1 楼和 7 楼厉害的
    wellsc
        11
    wellsc  
       2017-09-11 18:34:31 +08:00 via iPhone
    用法和 mongoengine hin 类似
    janxin
        12
    janxin  
       2017-09-11 21:46:27 +08:00 via iPhone
    在用一个轻量级的 umongo
    tonghuashuai
        13
    tonghuashuai  
       2017-09-11 21:52:41 +08:00
    用法类似 mongoengine,但是貌似对多个库的支持不好,现在一直在用 mongokit
    janxin
        14
    janxin  
       2017-09-11 21:58:30 +08:00 via iPhone
    @tonghuashuai 这个库不是好久没更新了吗
    tonghuashuai
        15
    tonghuashuai  
       2017-09-11 22:00:29 +08:00
    @janxin 对,是好久没更新了,新版本的 pymongo 都不能兼容,估计再往后用风险就比较大了……
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2801 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 67ms · UTC 12:53 · PVG 20:53 · LAX 05:53 · JFK 08:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.