title: How to perform Model Joins + Condition on Relations in Sails.js?
body: <p>How can I make a model join query(condition) and sort on relation models on Sails?</p>
  
  <p>Example: I have 4 tables(collections in mongodb) and 4 related models in mongodb:</p>
  
  <ul>
  <li>User: user_id, name</li>
  <li>Follow: user_id, following_id (user id is being followed)</li>
  <li>Point: user_id, point</li>
  <li>Post: name, content, user_id, created_at</li>
  </ul>
  
  <p>So from the post table, I want to make a query to find the posts of users that I'm following and sort by their point. Like this raw sql: </p>
  
  <pre><code>SELECT post.* FROM post 
  LEFT JOIN user_point up ON up.user_id = post.user_id
  WHERE post.user_id IN (1,2,3,4) // assume I got my following_user_ids result is 1,2,3,4 for this case so no need to join follow table
  ORDER BY up.point DESC // high point then first return
  </code></pre>
  
  <p>I don't know how can do this by Sails model? I have read many instructions by got no helps. Almost people said: Sails Association, but it just helps return the relation instead of do the where or order by to sort original model results(is this case: post).</p>
  
  <p>I have worked with Yii2, a PHP framework so with this case I can do it easily:</p>
  
  <pre><code>Post::model()-&gt;leftJoin('user_point up', 'up.user_id = post.user_id')-&gt;where(['post.user_id' =&gt; [1,2,3,4])-&gt;orderBy(['up.point' =&gt; SORT_DESC])-&gt;all();
  </code></pre>
  
  <p>I'm stucked in Sails, very thanks if someone help me!!! </p>