有谁知道如何使用 mongo alchemy 创建带有嵌入式文档的模型?我在文档中进行了搜索,但没有任何关于这样做的示例。
最佳答案
看看:
https://github.com/jeffjenkins/MongoAlchemy/blob/master/examples/examples.py
那里有一个示例,但为了完整性,是的 MongoAlchemy 可以使用这样的嵌入式文档:
class Address(Document):
street_address = StringField()
city = StringField()
state_province = StringField()
country = StringField()
class User(Document):
name = StringField()
email = StringField()
address = DocumentField(Address)
user = User()
user.name = "tony"
user.address = Address()
user.address.city = "London"
关于python - MongoAlchemy 嵌入文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14492641/