From 628ec452e966d964f397630e25ac019981854020 Mon Sep 17 00:00:00 2001 From: Rebecca Le <543859+sevenseacat@users.noreply.github.com> Date: Sun, 21 Apr 2024 18:54:13 +0800 Subject: [PATCH] docs: Fix filter semantics examples in Experssions guide (#1038) --- documentation/topics/reference/expressions.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/documentation/topics/reference/expressions.md b/documentation/topics/reference/expressions.md index a5b7c04e..3178b8d2 100644 --- a/documentation/topics/reference/expressions.md +++ b/documentation/topics/reference/expressions.md @@ -150,15 +150,15 @@ The filter refers to a _single post/comment/tag combination_. So in english, thi ```elixir def has_comment_with_more_points_than(query, score) do - Ash.Query.filter(Post, comments.points > 10) + Ash.Query.filter(query, comments.points > ^score) end def has_comment_tagged(query, tag) do - Ash.Query.filter(Post, comments.tag.name == ^tag) + Ash.Query.filter(query, comments.tag.name == ^tag) end Post -|> has_comment_with_more_points_than(query, 10) +|> has_comment_with_more_points_than(10) |> has_comment_tagged("elixir") ``` @@ -170,15 +170,15 @@ Lets rewrite the above using exists: ```elixir def has_comment_with_more_points_than(query, score) do - Ash.Query.filter(Post, exists(comments, points > ^score)) + Ash.Query.filter(query, exists(comments, points > ^score)) end def has_comment_tagged(query, tag) do - Ash.Query.filter(Post, exists(comments.tag.name == ^tag) + Ash.Query.filter(query, exists(comments.tag.name == ^tag) end Post -|> has_comment_with_more_points_than(query, ^score) +|> has_comment_with_more_points_than(10) |> has_comment_tagged("elixir") ```