Skip to content

Commit

Permalink
Update upgrade guide
Browse files Browse the repository at this point in the history
  • Loading branch information
Flo0807 committed Jan 24, 2025
1 parent b798243 commit facf5c5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions guides/upgrading/v0.11.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,31 @@ Update Backpex to the latest version:
In case you are using `Backpex.Resource` or one of the `Backpex.Adapter` modules (`Backpex.Adapters.Ecto` or
`Backpex.Adapters.Ash`) directly check out the updated function definitions. This will also apply in case you built your
own adapter.

## Make sure to cover all cases with the `item_query/3` function

We have removed code that ensures that a fallback item query function is always added to your LiveResource.

Make sure to always cover all possible cases or add a fallback `item_query/3` function that just returns the query.

For example:

```elixir
# in your resource configuration file (live resource)
use Backpex.LiveResource,
# ...other options
adapter_config: [
# ...other adapter options
item_query: &__MODULE__.item_query/3
]

def item_query(query, :index, _assigns) do
query
|> where([post], post.published)
end

# make sure to add this fallback function
def item_query(query, _live_action, _assigns) do
query
end
```

0 comments on commit facf5c5

Please sign in to comment.