title: Sequelize - How do I "select" instances of a model if a relation exists to another model
body: <p>I'm using PostgreSQL in a Node.JS app and I'm using SequelizeJS as an ORM. I have the following query:</p>
  
  <p>Let's say I have two models:</p>
  
  <ul>
  <li><code>User(name,email)</code></li>
  <li><code>Category(name,createdBy)</code></li>
  </ul>
  
  <p><code>Category.createdBy</code> is a foreign key referencing <code>User.id</code>
  These two tables have a many-to-many relationship:</p>
  
  <pre><code>Category.belongsToMany(models.User, {through: 'UserCategory'});
  User.belongsToMany(models.Category, {through: 'UserCategory'});
  </code></pre>
  
  <p>If a category is associated to a user, a mapping will exist on the UserCategory table. Else it won't.</p>
  
  <p>How to "select" instances which will find me all categories which are either createdBy a user X or associated to user X, i.e. <code>(categories associated to user X) + (categories created by user X)</code>?</p>