title: Combine multiple joins with filters in Vapor
body: <p>In my backend, I have <code>Post</code>s and a <code>PostController</code>. A post may be <code>visibleToFriendOnly</code>.<br>
  In <code>GET /posts</code>, I want to return all posts that the current user is allowed to see.<br>
  The <code>User</code> model has a <code>friends</code> property, that is a pivot of <code>User, User</code> with the columns <code>userID</code> and <code>friendID</code>.</p>
  
  <p>I currently get posts like this:</p>
  
  <pre><code>/// /posts
  func all(req: Request) throws -&gt; Future&lt;[Post]&gt; {
      let authenticated = try req.requireAuthenticated(User.self)
      return Post.query(on: req)
          .filter(\Post.visibleForUserType == authenticated.type)
          // FIXME: respect .visibleForFriendsOnly
          .all()
  }
  </code></pre>
  
  <p>I'm having a hard time with this because for each <code>Post</code>, I'd have to get the <code>userID</code> and then the <code>User</code> (who is the author) and then query the user's <code>friends</code> and see whether the current user is in that list.<br>
  Is there a feasible way of doing this? Maybe a join or something?</p>