Column 'aggregate' sum of 1:M entity column #1999
Unanswered
christiangroleau
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to better understand how to create the following scenario:
I have a parent entity column as a sum of values of a 1:M entity's column.
For example, I have 'Account' and 1:M 'Transactions' entity. The Account's 'Balance' column would be the sum of Transactions 'Values' column.
Currently, I am using Mikro ORM's Propagation to achieve this. Whenever I create a new Transaction, I update the Transaction's associated Account's balance then persist the Transaction.
My question: Is there a cleaner way of doing this?
Thank you!
I have provided a snippet of the code I am using.
My entities:
Beta Was this translation helpful? Give feedback.
All reactions