Woody88

Woody88

Is ORM the only way or the right way to design and deal with data?

Hi guys so I have been trying to build is small library app - the app just will ultimately allow users to reserve study rooms or auditoriums. It will also allow users to book and expert(just a person that has a certain skill they need, like math…) to help them with whatever needs they have. The app reads a CSV file that has all the library branches from the city and it also contains all the rooms that each branch have.

Ok, now the real issue. Due to the new suggest way of building things in Phoenix 1.3 (context) I have been trying to build my little elixir app following the context rule. I originally decided to use processes to hold my states such User, Branch, Room, Availability, and Reservation. But, It felt like I was starting to rewriting ORM crud operations. Thus, I decided to find something that did not require me to use Ecto because I was getting really confused on where to put schema, models and so on. I found this repo Moebius, as I’m using it I found my defining functions such as from_model, to_model basically mapping DB to my structs. Why? Well, this is what I have always learned from java, .net, Ruby and jumping to Phoenix.

I would like to know, can I just create my app without relying on structs to define my data and just use… I guess modules to define how to transform my data or what type of operation can be done with the retrieve DB data?

Pretty what is the right way? Or what the advantages and disadvantages between ORM and Directly just querying to you DB without transforming your data to a model?(Ecto vs Moebius?)

Whats is the correct or approved way of designing when it comes to this subject?

If feel like I am lacking some basic knowledge here, can anyone help?

Thank you.

Most Liked

michalmuskala

michalmuskala

Another important advantage of Ecto as a tool is that, as far as I know, it’s currently not possible to introduce, even by accident, an SQL injection vector using the query DSL - this is checked at compile-time.

OvermindDL1

OvermindDL1

The main advantage I see to using an ORM over raw calls is static ‘typing’ (at least making sure the names are correct) as I have a habit of mis-typing something and I like the compiler to catch me instead of getting a wtf SQL error later. ^.^

hubertlepicki

hubertlepicki

No, it’s not. Postgrex is pretty good on it’s own and not difficult to use. You can extend it’s functionality with type casting etc. to the level that can be very much all you need.
Check out: postgrex/lib at master · elixir-ecto/postgrex · GitHub

But I’m not advocating you do that, esp. if you just start with Elixir.

Where Next?

Popular in Questions Top

aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
vertexbuffer
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
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
mgjohns61585
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
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New

Other popular topics Top

hariharasudhan94
lets say i have a sample like a = 20; b = 10; if (a > b) do {:ok, "a"} end if (a < b) do {:ok, b} end if (a == b) do {:ok, "equa...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

Elixir Forum

We're in Beta

About us Mission Statement