I have a query that loads all messages in a chatroom:
room = conn.assigns[:room] |> Repo.preload(messages: from(m in Message, order_by: m.inserted_at))
I also want to have a users
variable that's a list of distinct/unique records that created these messages.
I could create a MapSet of user_ids
from room.messages
, and then query these users. But I wonder if there is a cleaner & more performant way to accomplish this?