Hi, I'm trying to learn the concept of CQRS and DDD. so I started a personal project. As of now I have only one object called appointment that is affected by typicel CRUD operations.
Since nestjs documentation is to say the less minimal. I looked for some implementations of CQRS using mongoose such as https://github.dev/kyhsa93/nestjs-rest-cqrs-example and https://github.dev/mguay22/nestjs-ddd.
I noticed both of this have something in common and is that they use an object factory. In the case of the second link, it uses a factory on top of the already existing schema, which is something I dont really understand why is neccesary, to me it just seems like a verbose and unnecessary layer since it doesnt even act as a middleware.
So I tried to implement it without said extra layer, making the schema itself extend from AggregateRoot. But now I get an error when doing a create operation.
TypeError: appointment.commit is not a function
For instance the object is correctly created in the db, it just fails when trying to commit it in the publisher
Is there something I'm missing here?
do I really have to create a factory to act as a another schema but extending from AggregateRoot?