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
Copy file name to clipboardExpand all lines: guides/live_resource/item-query.md
+6
Original file line number
Diff line number
Diff line change
@@ -25,10 +25,16 @@ use Backpex.LiveResource,
25
25
query
26
26
|>where([post], post.published)
27
27
end
28
+
29
+
defitem_query(query, _live_action, _assigns) do
30
+
query
31
+
end
28
32
```
29
33
30
34
The example above will filter all posts by a published boolean on `index` view. We also made use of the named binding. It's always the name of the provided schema in `snake_case`. It is recommended to build your `item_query` on top of the incoming query. Otherwise you will likely get binding errors.
31
35
36
+
Make sure to always cover all possible cases or add a fallback `item_query/3` function that just returns the query.
37
+
32
38
> #### Important {: .info}
33
39
>
34
40
> Note that it is not possible to use an anonymous function for `item_query` configuration. You must refer to a public function defined within a module.
0 commit comments