I have a function that deletes a specific document in MongoDb based on an id match. Below is the code snippet.
deletePoll: function(db, user_id, callback) {
db.collection('polls').deleteOne({
_id: user_id
},
function(err, result) {
if (err) {
console.log(err);
}
if(result){
console.log(result);
}
});
}
However, the above code only logs a large object when the if(result) condition is met. The object it logs is detailed below.
{ result: { ok: 1, n: 0 },
connection:
EventEmitter {
domain: null,
...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Even after manually checking the mongo console, the document remains undeleted. I'm puzzled as to why the document is not being removed. Additionally, why is the writeConcern object not showing up? Why is this extensive object being returned instead?