title: Mongodb: Combine $in and $nin
body: <p>In my collection <code>posts</code> I've documents like this  </p>
  
  <pre><code>[{
    _id : ObjectId("post-object-id"),
    title : 'Post #1',
    category_id : ObjectId("category-object-id")
  
  }]
  </code></pre>
  
  <p>I need to make some queries where I those a range of posts based on their category_id (can be multiple ids) but exclude some of them.</p>
  
  <p>I've tried with the query (in shell):  </p>
  
  <pre><code>db.posts.find({$and: [
    {_id: { $nin : ['ObjectId("post-object-id")']}}, 
    {category_id : { $in : ['ObjectId("category-object-id")']}}
  ]})
  </code></pre>
  
  <p>I returns 0 if count().</p>
  
  <p>However, if I change the category_id attribute and remove the $in and just include <strong>one</strong> ID it work, like this:</p>
  
  <pre><code>db.posts.find({$and: [
    {_id: { $nin : ['ObjectId("58a1af81613119002d42ef06")']}}, 
    {category_id : ObjectId("58761634bfb31efd5ce6e88d")}
  ]})
  </code></pre>
  
  <p>but this solution only enables me to find by one category.</p>
  
  <p>How would I got about combining $in and $nin with objectId's in the same manner as above?</p>