Email
|> limit(10)
# get a threads of these messages
thread_ids =
query_one
|> Repo.all()
|> Enum.map(& &1.thread_id)
# fetch all the messages of the treads.
final_query =
Email
|> where([e], e.thread_id in ^thread_ids)
|> Repo.all()
|> Enum.group_by(& &1.thread_id)
Короче вот через это я получаю желаемый output. Можно ли как-то оптимизировать?
thread_ids = from(m in Email, select: m.thread_id, limit: 10)
Можно по этому селекту еще один селект или джоин, если ч правильно понял задачу (читал по диагонали)
а как пустить селект по селкту?
from thread_ids …
Обсуждают сегодня