Came across this presumbly hard to fix issue around nested embeddables stored within element collections in MongoDB.
Consider MultiAddressAccount form EmbeddableTest. There we map the following (the object structure is account -> list of addresses -> address type):
db.MultiAddressAccount.find() { "_id" : "gunnar", "addresses" : [ { "street1" : "Piazza del Colosseo, 1", "name" : "primary", "postal_code" : "00184", "city" : "Rome", "country" : "Italy", "name" : "work" <-- that's the nested embeddable }, ... ] }
In a document store you'd rather do it like this, though:
db.MultiAddressAccount.find() { "_id" : "gunnar", "addresses" : [ { "street1" : "Piazza del Colosseo, 1", "name" : "primary", "postal_code" : "00184", "city" : "Rome", "country" : "Italy", "addressType" : { "name" : "work" } }, ... ] }
And that's how we actually would do it, if the embeddable was not part of a list but embedded directly.