You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* improvement: manual load can return list without :ok
This is a small improvement to commit 4e24d0f which will enable users to simply return a list from the manual relate without wrapping it as `{:ok, list}`
This is more in line with how calculations can return a list with or without :ok wrapping the result.
Notice that each item of the resulting list at a given index ends up being related to the record from the input list at the same index.
462
+
In other words, for an input record list `[r1, r2, ...]`, and an output list of `[s1, s2, ...]` the resulting relationships are `r1 -> s1, r2 -> s2, ...`.
463
+
464
+
This is similar to how [Module Calculations](documentation/topics/resources/calculations.md#module-calculations) are done.
465
+
466
+
> ### Returning a map? {: .info}
467
+
> At Ash version 3.14.1 and earlier, instead of returning a list from the `load/3` callback,
468
+
> it was necessary to return a map of input record ids to related records.
469
+
>
470
+
> Returning a map is still supported for backwards compatibility,
471
+
> but due to performance issues in certain cases it is recommended to return a list instead.
472
+
> Though it is supported, you should consider returning a map here as deprecated. Doing so may become unsupported in a future version.
473
+
>
474
+
> See issue [#2505](https://github.com/ash-project/ash/issues/2505) for more information.
475
+
458
476
### Reusing the Query
459
477
460
478
Since you likely want to support things like filtering your relationship when
@@ -496,15 +514,17 @@ defmodule Helpdesk.Support.Ticket.Relationships.TicketsAboveThreshold do
496
514
defload(records, _opts, %{query: query, actor: actor, authorize?: authorize?}) do
497
515
rep_ids =Enum.map(records, &&1.id)
498
516
499
-
{:ok,
517
+
tickets_by_rep =
500
518
query
501
519
# If this isn't added, representative_id would be set to %Ash.NotLoaded, causing the
502
520
# Enum.group_by call below to fail mapping results to the correct records.
0 commit comments