I have NodeJS with Mongoose and I'm accessing an API to retrieve data. I have a Schema as follows.
var dataSchema = new Schema({
id:Number,
name:String
));
And I'm using the following code to insert.
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();
}
});
But when I check my Mongo DB, I can still see duplicate entries.
Is there anther way?