title: Setting individual bits in mongo, to store a bitmask
body: <p>I want to store some flags into a mongo db. For now I have the following:</p>
  
  <pre><code>&gt; db.test.save({a:0x1})
  &gt; db.test.save({a:0x3})
  &gt; db.test.save({a:0x2})
  &gt; db.test.save({a:0x2})
  &gt; db.test.save({a:0x4})
  &gt; db.test.save({a:0x5})
  &gt; db.test.find({'$where': "this.a &amp; 0x1"})
  </code></pre>
  
  <p>Is there a more effective way?</p>