As you can see each bill could have multiple items and multiple payments of different “paymentTypes” (in this case cash and card). My question is how would I could the total values (from “amount”) of the “payments” in each bill grouped by the payment type? Looking at “@groupby” I see I can only really get count(uid) or other aggregators from that.
It’s very clear to me that I’m just not thinking in a properly dgraph way yet. I’m sure this problem is pretty trivial, but some pointers towards how I need to think about this would really help
Thanks for replying! But clearly my question was badly formed. What I’m looking for is a query that would give me the total value of payments grouped by payment type. In the case I put in the original question, I would get:
total: 20
cashTotal: 23 (8 given as change)
cardTotal: 5
I’m so backwards when it comes to dgraph. It hadn’t occurred to me to use the reverse edge on payment type to get the amount.
Now I just need to figure out how to do this on a specific subset of bills (based on datetime). I’m guessing a combination of var queries (one for the bills in question, to get the uid of the payments associated with those bills, then use that collection of uids as a filter for the “~paymentType” edge)