Question
How to implement a Repository in DDD correctly
I have a question regarding DDD and the repository pattern.
I have an AggregateRoot Report that has Transactions (which is an Entity Array).
I used to have a CRUD repository and when I was modifying a transaction I used to fetch the report, apply my domain method and save the report and that was working when I was using a NoSQL database as I had a single Document.
Problem: I switched to RelationalDB and now if I were to e.g. add a transaction I wouldn't be able to simply save the whole aggregate in the database as Transactions are in a different table and I would have to only add a row in that table. If I have the whole aggregate I have to take a delta to understand what it needs to update.
Solution 1: The first thing that comes to mind is to use repository methods like AddTransaction(reportId, transaction) instead of update, but I worry that information is leaked to the repository and also it troubles me that a change in the DB made my change my ApplicationLayer and possibly the domain layer as now I would have to return the created transaction from the domain in order to save it.
Solution 2: Another interesting approach is to create a domainEvent with all the relevant information e.g. TransactionCreated(Transaction) and in the repository I could read this event and then do the relevant changes like solution 1.
Both approaches suggest changes to Application and Domain layer because I changed database which is the whole concept of DDD. Is the CRUD repository only for small aggregates? I would highly appreciate your feedback and ideas.