一起使用 MongoEngine 和 PyMongo [英] Use MongoEngine and PyMongo together

查看:118
本文介绍了一起使用 MongoEngine 和 PyMongo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的下一个项目中使用 MongoEngine.现在我想知道我是否也可以在同一个项目中直接使用 PyMongo.只是因为我需要一些非常特别的东西,而 mongoengine 不直接支持.

I want to use MongoEngine for my next project. Now I'm wondering whether I could also use PyMongo directly in the same project. Just for the case that I need something very special that is not supported directly via mongoengine.

有没有怀疑这会起作用,或者我不应该这样做!?

Are there any doubts that this would work, or that I should not do that!?

推荐答案

这里是 MongoEngine 的作者 - MongoEngine 是建立在 pymongo 之上的,所以你当然可以进入 pymongo - 或者在你的代码中使用原始 pymongo!

Author of MongoEngine here - MongoEngine is built upon pymongo so of course you can drop into pymongo - or use raw pymongo in your code!

有一些文档助手允许您访问 MongoEngine 中的原始 pymongo 方法,例如:

There are some document helpers that allow you to access raw pymongo methods in MongoEngine eg:

class Person(Document):
    name = StringField()

# Access the pymongo collection for the Person document
collection = Person._get_collection()
collection.find_one()  # Use raw pymongo to query data

这篇关于一起使用 MongoEngine 和 PyMongo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆