title: NodeJS, Mongoose - Duplicate entries when inserting data
body: <p>I have NodeJS with Mongoose and I'm accessing an API to retrieve data. I have a Schema as follows.</p>
  
  <pre><code>var dataSchema = new Schema({
    id:Number,
    name:String
  ));
  </code></pre>
  
  <p>And I'm using the following code to insert.</p>
  
  <pre><code>  var d = Data.find({id:data.id}, function(error, curr_data) {
      if(curr_data.length == 0) { // check to make sure only unique entries are entered
        console.log("      Inserting : " + curr_data.name);
        new Data(data).save();
      }
    });
  </code></pre>
  
  <p>But when I check my Mongo DB, I can still see duplicate entries.</p>
  
  <p>Is there anther way?</p>