Is it possible to "pluck" a sibling using an expr?
I have resources
- Group -> has_many formations
- Formation (group_id, lithostrat_order)
I would like to have a calc on formation that goes via parent group to select a formation with lithostrat_order + 1
I am almost there with:
But this will return more than one unless I am at the second to top one when resolving this 😄
Solution:Jump to solution
so I've done stuff like this before with a relationship. eg. this is for a set of records called OperationExecutions:
```elixir
has_one :previous_execution, MODULE do
no_attributes? true...
4 Replies
Solution
so I've done stuff like this before with a relationship. eg. this is for a set of records called OperationExecutions:
I've been meaning to write up a blog post about tricks like this
ah yes no attr is a much better approach
basically,
no_attributes? true
will unset all default filters to return all records, and then it gets scoped down to those with the same operation_version_id
that were created earlier, and then the has_one
/sort
limit it to only the correct recordI even have this trick active in my codebase
just total brainfart that I was reaching for a calc 😂
thank you very much for reminding me