bgpratt2000
How to write Ecto queries without PostgreSQL views?
Hi! I’m super new to ecto and struggling with writing queries without using the postgreSQL views that I learned in college.
So what I’m wondering is:
Given the following schemas:
schema "s1" do
field :f1, :dtype1
field :f2, :dtype2
belongs_to :b1, B1
belongs_to :b2, B2
belongs_to :b3, B3
end
schema "s2" do
field :f3, :dtype2
belongs_to :b1, B1
belongs_to :b2, B2
belongs_to :b3, B3
belongs_to :b4, B4
end
how do I join s1 with s2 on b1, b2, and b3 without doing a million joins and associations?
In the end I actually want to update every instance of s1.f2 to be equal to the corresponding s2.b4.
THANKS!!!
Most Liked
Hermanverschooten
Hi and welcome.
There is no rule saying you cannot use views in ecto, you just replace your schema name with the name of the view.
2
Popular in Questions
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Student & New to elixir. Nice language.
I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
I would like to know what is the best IDE for elixir development?
New
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
Hello everybody,
usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Other popular topics
Manning 2016 Halloween weekend sale via Deal of the Day
Friday, October 28 - Half off all MEAPs - code WM102816LT
Saturday, October 29 ...
New
This release brings a number of exciting features, including integration with the new Phoenix LiveDashboard and Phoenix LiveView. There h...
New
As many of you may have realized by now (sorry for all the posts here) I’ve been working on a db problem where I’m trying to aggregate a ...
New
What is most correct way to open, read and parse JSON file with poison?
For example if we have example.json file in root of some projec...
New
Could someone help me? I'm making my first elixir program, number guessing game. I can't figure out how to convert the user's guess from ...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New







