title: Check if value exist in mongo collection
body: <p>I'm working in node js  and I'm using mongo (Im absolute beginner) . Now I need to have collection that basically needs to look like this array </p>
  
  <p><code>var keys = ['key1','key2','key3']</code> // with this I easily can check if some value I have exist in this array with indexOf function , </p>
  
  <p>Now I need to make collection in mongo that only needs to store keys that user makes and if key already exist in collection it need to do nothing.</p>
  
  <p>//My keys looks something like this , it can be one string or it can be an array of string</p>
  
  <pre><code>Keys = 'home4.car3' or Keys = ['home4.car3','home2.car4']
  </code></pre>
  
  <p>// I'm doing insert like this </p>
  
  <pre><code>db.collection('keys',function(err, collection){
              collection.insert(Keys, {safe:true}, function(err, result) {
                  if (err) {
                      res.send({'error':'An error has occurred'});
                  } else {
                      console.log("success");
                  }
              });
          });
  </code></pre>
  
  <p>NOW Here is what happened when I first insert array of two keys into db , and then after that one string :</p>
  
  <p><a href="https://gist.github.com/anonymous/fc7730e398519cffde3f" rel="nofollow noreferrer">https://gist.github.com/anonymous/fc7730e398519cffde3f</a></p>
  
  <p>Does anyone can tell me how to to insert for this and how to filter those keys to check if they are into collection?</p>