I wouldn't claim this is a good idea because `into` in your example looks like 
leakage of app logic into DB level. If you're only ought to create user id - 
user map, it is pretty easy to do in Elixir from just a list of users. If you 
concerned about memory/time, you could try streaming from repo. If your data is 
inevitably key value table, then maybe you better off using JSONB column for 
storing maps, or even exploring document DBs.

-------- Original Message --------
On 31 Aug 2022, 23:54, Yusuf wrote:

> Hello everyone,
>
> This is my first time posting, please excuse me if I did something wrong :)
>
> I am writing a query like below,
>
> query =
> from u in User,
> where: u.id in ^user_ids,
> select: {u.id, u}
>
> data =
> query
> |> Repo.all()
> |> Enum.into(%{})
>
> As follows, Does it make sense to add the "into" keyword into to this query?
>
> query =
> from u in User,
> where: u.id in ^user_ids,
> select: {u.id, u},
> into: %{}
> data =
> query
> |> Repo.all()
>
> I would like your thoughts on this one.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "elixir-lang-core" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to elixir-lang-core+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> [https://groups.google.com/d/msgid/elixir-lang-core/0e57204b-302b-494e-bcce-e0d1776218a8n%40googlegroups.com](https://groups.google.com/d/msgid/elixir-lang-core/0e57204b-302b-494e-bcce-e0d1776218a8n%40googlegroups.com?utm_medium=email&utm_source=footer).

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/pZPPaXUjy3yeNrbXhyVbkSVYiqQ2Y-eY9zGG5lFsDuaNOxnuEE8adobuRz5nlc9qwvOp7jrsj0aNev5OPn-pP5rFUzNIg1gvPXf1RUH1GHY%3D%40pm.me.

Reply via email to