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):
{code} 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 }, ... ] } {code}
{code} 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 }, ... ] } {code}
In a document store you'd rather do it like this, though:
{code} db.MultiAddressAccount.find() { "_id" : "gunnar", "addresses" : [ { "street1" : "Piazza del Colosseo, 1", "name" : "primary", "postal_code" : "00184", "city" : "Rome", "country" : "Italy", "addressType" : { "name" : "work" } }, ... ] } {code}
And that's how we actually would do it, if the embeddable was not part of a list but embedded directly. Unfortunately we don't receive the name of the embeddable in {{insertOrUpdateAssociation()}}, though. So we cannot create such structure atm.
|