Skip to content

Commit b824bd0

Browse files
committed
Update item query guide
1 parent 13c5603 commit b824bd0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: guides/live_resource/item-query.md

+6
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,16 @@ use Backpex.LiveResource,
2525
query
2626
|> where([post], post.published)
2727
end
28+
29+
def item_query(query, _live_action, _assigns) do
30+
query
31+
end
2832
```
2933

3034
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.
3135

36+
Make sure to always cover all possible cases or add a fallback `item_query/3` function that just returns the query.
37+
3238
> #### Important {: .info}
3339
>
3440
> 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

Comments
 (0)