Reading the code here and seeing this:
arr._id = arr.id + '';
if(Wordpress.findOne({_id : arr.id + ""})){
Wordpress.upsert(arr._id,arr)
}else{
Wordpress.insert(arr);
}
Why do the findOne() and then .upsert() instead of just calling .upsert() directly?
The second parameter to .upsert() should be a Mongo modifier rather than an actual object. I'd guess that the code above doesn't really upsert() a document. It probably needs to be refactored to Wordpress.upsert(arr._id,{$set: arr}) for the .upsert() to succeed.
Reading the code here and seeing this:
Why do the
findOne()and then.upsert()instead of just calling.upsert()directly?The second parameter to
.upsert()should be a Mongo modifier rather than an actual object. I'd guess that the code above doesn't reallyupsert()a document. It probably needs to be refactored toWordpress.upsert(arr._id,{$set: arr})for the.upsert()to succeed.