When working with OGM an existing database, it would be very useful to allow to propagate any unmapped attributes of a record/document in a generic container.
Taking a web shop with a Product entity as example, you typically don't need to (or even can) "know" all the attributes of such a product entity but still want to be able to display all the attributes in a generic fashion e.g. on a web page. Only a few attributes actually need to be known/mapped in the application itself, namely those fields to which specific handling/logic applies.
To facilitate such a scenario, one could designate a Map property of an entity to hold any unmapped attribute.
Considering e.g. the following MongoDB document:
This could be mapped to a Product entity like this:
While the attributes common to every product document are explicitly mapped as properties, all unmapped properties are exposed via the additionalProperties map which is designated for that purpose using a new annotation, e.g. named @AdditionalProperties. The application can perform logic on the common known attributes and still forward all unmapped attributes to a generic web view etc.The types of the map values would be those returned from the underlying store.
Such a facility would also help with prototype development, where one starts with most attributes not being explicitly mapped and then creates specific members iteratively as application requirements demand.
Also the CouchDB dialect would benefit from this, because it doesn't support partial updates at the moment, meaning one currently must map all attributes or an update (which always writes back a complete document) may discard any unmapped attributes.