Reputation: 10906
Does anyone know how to create a model with an embedded document with mongo alchemy? I've search in the documentation, but there isn't any example about doing that.
Upvotes: 2
Views: 1182
Reputation: 4296
have a look at:
https://github.com/jeffjenkins/MongoAlchemy/blob/master/examples/examples.py
Theres a sample there, but for completeness, yes MongoAlchemy can use embedded documents like this:
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"
Upvotes: 3
Reputation: 4910
I didn't see anything in mongoAlachemy
for embedded documents:
see here:
I suggest you use mongoengine
for better result:
Upvotes: 1