Skip to content

Blending ORM and ODM but keeping the Domain Model clean #2

@webdevilopers

Description

@webdevilopers

When trying to use Doctrine ORM Entities with ODM Documents (e.g. MongoDB) most solutions adding extra fields:

For me this feels like "polluting" the Domain Model with extra properties to fit the infrastructure.
So I am currently looking for a way to keep the Domain Models clean:

A possible workaround could be a custom mapper:

A different solution could be treating referenced entities as Value Objects which at the same time could serve as a historical "query database".

For instance:
Instead of linking an ODM Order Document (still an "Entity" in DDD though) with an ORM Customer you introduce a Customer Value Object that keeps Id and full name. Maybe the delivery and / or invoice address too.

Remember kids:

Implementation issues (such as persistence) are not dealt with in the model, but they must be in the design.” - @ericevans0
https://twitter.com/fromddd/status/725604978564308992

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions