I have a mongoose Model, I try to remove all documents from a collection but after I run the code, the collection remains unmodified. Please see the code below:
return ProcessedStats.remove({}).then(function (d) {
console.log(d);
return ProcessedStats.find({}).count().then(function(c) {
console.log(c);
});
}).then(function() {
db.disconnect();
});
I call remove with an empty object, so to remove all documents, when I call find, I still have the count to 16000 documents.
What could be wrong?
Weird: if I do
find({})
and prin out data.length it equals 0, but if I do
.find({}).count()
it will equal 16000. What is wrong with the behaviour? What am I missing?
I think it was a caching issue, after I restarted the server, the count was ok