updated_at = Map.get(params, "updated_since", "1970-01-01T12:00:00")
query =
from m in ChatMessage,
join: u in assoc(m, :chat_user),
order_by: [asc: m.updated_at],
where: u.chat_id ==^ id,
where: m.updated_at > ^updated_at
I added the parameter updated_since as optional parameter to some api calls.
I don’t want to use Map.get in all controllers and added a methode for this:
def check_updated(query, params) do
case Map.get(params, "updated_since") do
nil -> query
updated_since -> query |> where(updated_at: > ^updated_since)
end
end
I get a SyntaxError and think this is wrong anyway.
What would be the right way to implement a method to extract where: xyz.updated_at > ^updated_at
to a central method?