问题
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!?
回答1:
Author of MongoEngine here - MongoEngine is built upon pymongo so of course you can drop into pymongo - or use raw pymongo in your code!
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
来源:https://stackoverflow.com/questions/12068558/use-mongoengine-and-pymongo-together