Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I started using Sequelize in Express.js app. Soon enough ran into issues of the nature you're describing. Maybe I did not quite understand Sequelize, but to me doing things more than just selecting from one table wasn't really convenient. And where ordinarily you would use select from two or more tables, or a union in pure SQL, you would have to run separate queries, and with the async nature of Node it's just added complexity. </p> <p>Therefore I moved away from using Sequelize. Moreover I am switching from using ANY data fetching from DB in the models. In my opinion it is better to abstract getting data completely. And reasons are - imagine that you don't just use MySQL (in my case, I use MySQL and MongoDB side by side), but you can get your data from any data provider and any transport method, e.g. SQL, no-SQL, filesystem, external API, FTP, SSH etc. If you tried to do all of it in the models, you would eventually create complex and hard to understand code that would be hard to upgrade and debug.</p> <p>Now what you want to do is to have models get data from a layer that knows where and how to get it, but your models only use API methods, e.g. <code>fetch</code>, <code>save</code>, <code>delete</code> etc. And inside this layer you have specific implementations for specific data providers. E.g. you can request certain data from a PHP file on a local machine or from Facebook API or from Amazon AWS or from remote HTML document, etc.</p> <p><strong>PS</strong> some of these ideas were borrowed from <em>Architect</em> by <em>Cloud9</em>: <a href="http://events.yandex.ru/talks/300/" rel="noreferrer">http://events.yandex.ru/talks/300/</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload