title: Peewee: filtering by many-to-many relationship
body: <p>Here's a basic example - posts are owned and liked by users. How to select liked posts for specific user?</p>
  
  <pre><code>import datetime
  import peewee
  
  class User(peewee.Model):
      name = peewee.CharField(max_length=200)
  
  class Post(peewee.Model):
      user = peewee.ForeignKeyField(User)
      text = peewee.TextField()
  
  class Like(peewee.Model):
      user = peewee.ForeignKeyField(User)
      post = peewee.ForeignKeyField(Post)
      time = peewee.DateTimeField(default=datetime.datetime.now)
  </code></pre>
  
  <p>I make a query from perspective of Like model, starting query with <code>Like.select()</code> and join <code>Post</code> model. Is it ok? How could I query from perspective of <code>Post</code> model, i.e. <code>Post.select()...</code>?</p>
  
  <p>Here's a complete sample for convinience:</p>
  
  <pre><code>def check_likes():
      user, _ = User.get_or_create(name="John")
      post, _ = Post.get_or_create(text="Hello world!", user=user)
      like, _ = Like.get_or_create(post=post, user=user)
  
      print("Created: ", user, post, like)
  
      # Get liked posts for user
      query_likes = (Like.select()
          .where(Like.user == user)
          .join(User)
          .join(Post))
      liked_posts = [like.post for like in query_likes]
  
      print("Liked posts: ", liked_posts)
  
  if __name__ == '__main__':
      User.create_table(True)
      Post.create_table(True)
      Like.create_table(True)
  
      check_likes()
  </code></pre>
  
  <p>UPD. I ended up with such query at the moment:</p>
  
  <pre><code>def liked_by(user_id):
      """Active posts liked by user."""
      return (Post.select(Post, User, Like)
          .join(User, on=(Post.user == User.id))
          .switch(Post)
          .join(Like, peewee.JOIN.LEFT_OUTER,
                on=(Like.post == Post.id).alias('like'))
          .where(Like.user == user_id)
          .order_by(Like.time.desc()))
  </code></pre>