DDD and MongoDB: Is it possible to let Mongo create ObjectIDs?

According to DDD (Blue book, Evans), Factory is responsible for creating a consolidated root in a valid state. Does this mean that he should be able to create a technical identifier (objectId in the mongoDB world), as well as a domain identifier?

On the one hand, this seems like a technical detail, and it would be nice if Mongo had done the job of creating an identifier.

On the other hand, including an id request (through getByIdthe DDD repository) provides a technical identifier for the domain, which, in turn, is responsible for creating the Factory to create it.

Perhaps I can’t make out the various use / overlap options, etc. Technical Id vs DomainId or maybe I'm overdoing it, but I would still appreciate your opinion.

In short: In DDD: Should Factory create a technical identifier as well as a domain identifier?

possible implementation: Hi / Lo ( How to set the initial value of the hilo sequence in Normo MongoDB? )

EDIT: although the hi / lo method provides Factory for the persistence layer that only the repository should know. hmmm

thank

+5
source share
1 answer

, . , , , UUID/GUID, factory , , , .

. , MongoDB , , , MongoDB .

+3

All Articles