DEV Community

loading...

Discussion on: Sequelize and MySQL debugging quick tips

Collapse
rehanvdm profile image
Rehan van der Merwe

[Opinion] My number 1 tip is to not use ORM.

What is your thoughts around that?

I have just found that pure SQL is better within the team as it does not require to learn another framework/library, you have much better control over meaning you explicitly tell SQL what you want, so it is really simple. With ORMs they *might always do some joins unknowingly or write unoptimized queries missing the indexes. It also makes migrations difficult *if you ever need to change data stores.

Collapse
dvddpl profile image
Davide de Paolis Author

I kinda expected this comment :-)
i don't have a strong opinion about it. we had a similar project 3 years ago where we used plain SQL scripts and it was quite straightforward at the beginning, but as the project grew we ended up with lots of boilerplate, redundant code, very hard to debug parts and writing complex performant queries was also quite difficult, especially for junior/regular fullstack dev ( which normally don't have a deep understanding/knowledge of DBs).
With the latest project we gave ORM a try and I really like how easy it was to set up tables/models. ( and even with migration / changes to the tables) i find it interestingly easy. Furthermore you have a lot of utilities ready and validation and hooks and the "language" is easier to grasp for devs.

Of course this comes to a cost, learning how that specific library does things ( because Sequelize is different from TypeORM for example) and it generally keeps you away from understanding the real thing ( pure SQL) which imho is more important. (that's why i started digging a lot in the debugging part and in the generated queries ) .
In the end as usual, it is a balance between project size, team member skill level and overall speed/deadlines.

Collapse
rehanvdm profile image
Rehan van der Merwe

Excellent reply! :) Agree with it 100%, might give it a try next time or in a side project and see how it goes.

Thanks I did not consider the scenario of a language/framework being easier to learn for Juniors than actually learning SQL.