Another calculations query
I have 'Job' which is related to a 'Service' via another resource (not defined as a :through).
I need a calculation that does something like
I've already defined the
first
aggregates, but now I'm getting an error telling me that I need to provide field type for first
, so I'm assuming that something along my chain of first aggregates is not working?
or am I not allowed to define an aggregate of an aggregate?17 Replies
side note, are there any plans to add
:through
support to has_one
?not "plans" specifically, but would be great 😄
I'm assuming it's not working because I have an aggregate of an aggregate
Yep
Aggregates over aggregates aren't supported currently
Can you lift up the aggregate?
like adding
first :thing, [:foo, :bar, :baz], ...
will that automatically load things in the path?
What do you mean load things in the path?
it will happen in the query
aggregates support a single relationship or relationship path
first :track_weight, [:order_service, :service], :track_weights_on_pickup_and_empty
??yeah, exactly
order_service is a resource, as is service
assuming those are the relationship names
didn't know that was supported 🙂
we also recently optimized
first
when used across exclusively belongs_to
relationship paths
where it will just do a simple join and select, not the normal aggregate logicwas this the stuff in main liners?
You can do the same thing for all of the aggregates, can be really useful sometimes.
Yep! Although relationship paths in aggregates has been supported since the beginning
TIL 🙂
let's say you have a boolean, can you just reference it in an expression like
expr(status == :foo and track_weights?)
assuming it's defined as track_weights?
yeah, should be able to 👍
thankyou 🙏🏿