烧瓶和蒙戈
考虑到完全构建在 MongoDB 之上的 Web 服务,虽然我对 PyMongo 非常满意,但我想知道你们对这些 ODM 是否有任何积极或消极的经验/故事:MongoKit、MongoEngine 和 MongoAlchemy,后者有一个特定于 Flask 的包“Flask-mongoalchemy”。
Thinking of a web service entirely built on top of MongoDB, while I am pretty confortable with PyMongo, I would like to know if you guys have any positive or negative experiences/stories about either of these ODMs: MongoKit, MongoEngine and MongoAlchemy, the latter having a Flask specific package "Flask-mongoalchemy".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我使用 MongoEngine 和 Flask 没有问题。我们编写了(收集的资源),其中还包括 wtform 支持和 Flask-debugger 支持:
https:// github.com/MongoEngine/flask-mongoengine/
I use MongoEngine with flask no problems. We've written (collected resources) which include wtform support and flask-debugger support as well:
https://github.com/MongoEngine/flask-mongoengine/
我真的没有任何真实的经验或故事可以提供,但我同时使用了 MongoKit 和 MongoAlchemy,我个人决定尝试 MongoAlchemy,因为我更喜欢它的语法(可能是由于我的 Django 传统)。
MongoKit:
MongoAlchemy:
两者都将帮助您验证数据,让您强加诸如模式之类的东西(仅在应用程序级别),并节省您的打字时间(特别是括号)。
MongoKit 更加完整。我选择 MongoAlchemy 是因为我不想一直输入
struct = {}
,并使用con.test.example.BlogPost()
指定您的数据库和集合感觉不对(尽管你不必这样做)。两者都尝试一下,然后选择最适合您的一个。
正如您已经提到的,有一个 Flask-MongoAlchemy 扩展,效果很好。
如果您想使用 MongoKit,优秀的 Flask 文档将立即帮助您上手:
http://flask.pocoo.org/docs/patterns/mongokit/
很棒的是,您只需可以尝试一个,如果您不喜欢它,您可以切换到另一个,或者直接使用 pymongo,而无需更改数据库中的任何内容。
I don't really have any real experience or story to offer, but i played with both MongoKit and MongoAlchemy, and i personally decided to try MongoAlchemy, because i like the syntax a little better (probably due to my Django heritage).
MongoKit:
MongoAlchemy:
Both will help you to validate your data, will let you impose something like a schema (only on application level), and will save you some typing (specifically brackets).
MongoKit is more complete. I chose MongoAlchemy because I didn't want to type
structure = {}
all the time, and specifying your db and collection usingcon.test.example.BlogPost()
just felt wrong (although you don't have to do it this way).Try both, and choose the one which works better for you.
As you already mentioned, there is a Flask-MongoAlchemy extension, which works great.
If you want to use MongoKit, the excellent Flask documentation will get you going in no time:
http://flask.pocoo.org/docs/patterns/mongokit/
The great thing is that you just can try one, if you don't like it you can switch to another, or drop to pymongo without having to change anything in the database.