adamlibusa

adamlibusa

Is there somebody who could coach me over Skype on Ecto and help me solve a quite trivial problem: Build a tree-like structure of entities, based on a table that references itself. I am ready to pay, if it is a reasonable amount of money.

I feel that either Ecto and Elixir are not the right tools for it, or I simply don’t have enough experience with these tools to figure it out on my own, just with books and tutorials. After about two months of struggling, I am ready to give up on Elixir. And I really don’t want to, because it looks like a neat tool.

Thank you and sorry if this kind of requests doesn’t belong here. I will understand removing it, if that’s the case.

Showing Posts 1 to 4

rms.mrcs

rms.mrcs

So, I see that you wrote this thread a few days ago.

I’m far from a specialist, but maybe I could help. I’ve made something similar to this problem.

From your original post, I think the problem could be in your changesets. Usually all you need is to use put_assoc or cast_assoc and Ecto will build your associations in the database. Can you post them?

michalmuskala

michalmuskala

I replied to a similar question in another thread: Ecto preload for tag has_many tags - #3 by michalmuskala

To summarise, asking “How to do this in ecto” is the wrong question. The right question is “How to do this in SQL”. Ecto, differently from ORMs (and that’s probably the important difference, not the fact that elixir doesn’t have objects), keeps close to the semantics of the underlying data storage and does not try to abstract it. This means that to use Ecto efficiently, one should understand the database.

adamlibusa

adamlibusa OP

Michal, thank you for your answer. Writing up a Postgres query that would load the tree data and make it work took me an hour. And I don’t agree that expressing a precise query for this is not possible: “WITH RECURSIVE” in Postgres or “START WITH … CONNECT BY” in Oracle are tools made exactly for this case.

What drives me nuts is how to build a tree of Ecto entities in memory, using put_assoc, given that I already have a 2D list of data from the DB (that was the easy part). I will try a couple more things and if they don’t work, I will post my code, as a reaction to rms.mrcs.

adamlibusa

adamlibusa OP

rms.mrcs, thanks for the answer. I was doing some research and this post on Stackoverflow helped me realize something:

Working with trees in a compulsory immutable environment will be pain in the ass no matter what. Building trees in Elixir is really hammering nails with a screwdriver. I will probably change the framework, since I don’t want to have to write 300 line module, just to build a simple tree. Thank you for your help though.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
samoloth
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews