F
Filamentβ€’9mo ago
smoothtire

Count SaleItems sold by Product ID

Hello, I have a Sales Resource with (hasMany) SaleItems Resource which selects a product to sell from the Product table. I'm looking to have a column in my Product table that sums all the related product sales to give a Sold total. I've read through the docs and finding this particular issue to be a little tricky. Any help is appreciated!
8 Replies
smoothtire
smoothtireOPβ€’9mo ago
migrations
No description
No description
No description
smoothtire
smoothtireOPβ€’9mo ago
product table?
No description
krekas
krekasβ€’9mo ago
I think you should create an attribute and count the sum there
smoothtire
smoothtireOPβ€’9mo ago
Thank you @krekas, I'll look into that!
dissto
disstoβ€’9mo ago
Take a look at withSum And please dont use decimal/floats for currency values And next time please use real code and not images πŸ˜‹
smoothtire
smoothtireOPβ€’9mo ago
Thanks @dissto! Sorry! @dissto From what I'm seeing, withCount will count the amount of relationships, right?
dissto
disstoβ€’9mo ago
Yes, but I wrote to take a look at withSum not withCount πŸ˜‹
smoothtire
smoothtireOPβ€’9mo ago
Haha, oops! Thank you
Want results from more Discord servers?
Add your server