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

RSP87
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
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
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
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
FlyingNoodle
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
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
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
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews