juanldslv

juanldslv

What is the meaning of '=>' ? Repo.all()

Hi guys, I hope that all are good, now, Im trying to make a query into a function but when I sent the query for repo.all, this is the answer is ‘=>’ that the repo give me. does anyone know about it ? :thinking:

defp historia_clinica_medico(paciente)do

IO.inspect(Repo.all(from h in Sim.HistorialHistoriaClinica, where: h.paciente_id == ^paciente
                                                                 and not is_nil(h.historiaclinicamedico_id), select: h.historiaclinicamedico_id))

end

thank you for all advices as much as code or my poor English language

First 6 of 6 Posts Switch mode

peerreynders

peerreynders

There really isn’t enough information to give an answer. For example:

iex(1)> alias MusicDB.Track
MusicDB.Track
iex(2)> import Ecto.Query
Ecto.Query
iex(3)> album_id = 5
5
iex(4)> IO.inspect(Repo.all(from t in Track, where: t.album_id == ^album_id and not is_nil(t.id), select: t.id))

20:04:17.914 [debug] QUERY OK source="tracks" db=2.0ms
SELECT t0."id" FROM "tracks" AS t0 WHERE ((t0."album_id" = $1) AND NOT (t0."id" IS NULL)) [5]
[33, 32, 31, 30]
[33, 32, 31, 30]
iex(5)>

=> typically appears in the representation of Elixir maps where the keys aren’t atoms.

iex(5)> IO.inspect(Map.new([{"a",1},{"b",2}]))
%{"a" => 1, "b" => 2}
%{"a" => 1, "b" => 2}
iex(6)> 

juanldslv

juanldslv OP

Peerreynders may you check the controller ?
https://gist.github.com/juanldslv/e03a05244f6dc1a2c86869331f844ff8

david_ex

david_ex

This looks suspiciously like iex displaying a list of integers as charlists. Can you try the following in iex?

result = Repo.all(from h in Sim.HistorialHistoriaClinica, where: h.paciente_id == ^paciente
        and not is_nil(h.historiaclinicamedico_id), select: h.historiaclinicamedico_id)

inspect result, char_lists: :as_lists

i result

Does the result make more sense to you? If yes, you can find more information about it in the charlists section of the guide, and this issue has helpful information also.

peerreynders

peerreynders

In particular:

iex(1)> list_of_ids = [61, 62]
'=>'
iex(2)> IO.inspect(list_of_ids)
'=>'
'=>'
iex(3)> IO.inspect(list_of_ids, [charlists: :as_lists]) 
[61, 62]
'=>'
iex(4)> to_string(list_of_ids)
"=>"
iex(5)>

i.e. the query returned a list of two historiaclinicamedico_id values, 61 and 62 respectively.

juanldslv

juanldslv OP

Thank you @david_ex, that works like a charm… best regards :robot: :+1:

juanldslv

juanldslv OP

Thank you @peerreynders , that works like a charm… best regards :robot: :+1:

— All posts loaded —

Where Next?

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
jonnycharles
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
spammy
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
silverdr
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated! To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead. Sta...
New
dli
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app? Looking for hints regarding: Addi...
New
bottlenecked
Hi all, I wanted to ask how the community is dealing with post-release steps. Today we have Ecto migrations, which make sure that the db...
New
michallepicki
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
akoutmos
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New

We're in Beta

About us Mission Statement