0

I find that when I run the remove() command on mongodb-native for node.js, the document is removed but it's _id remains. So after performing a bunch of deletes I'm stuck with these empty objects with only an _id.

This is odd considering if I call remove() with no arguments, it cleans out the entire collection with no trace.

There must be a way to completely remove a document.

UPDATE

I've been asked to clarify. Say I have a single document in my collection. It has a name and a value as well as the built in _id that mongo adds on insert. I call collection.remove( { name:name } ) and after it completes theres still a document in my collection with that old document's _id and nothing else.

Josh Elias
  • 3,250
  • 7
  • 42
  • 73
  • 1
    Do I understand you correctly that there's still an object in the collection after you removed it? Is that document really still there, i.e. also when you call `find()` from the mongodb console? – mnemosyn Feb 19 '14 at 17:01
  • 1
    Could you please provide an example of how to reproduce this behavior? – WiredPrairie Feb 19 '14 at 18:31
  • I've tried to clarify. – Josh Elias Feb 19 '14 at 19:04
  • Sounds like a severe bug, it's so bad that I can't image it's caused driver - that would be known. Use the mongodb profiler to log all requests (`db.setProfilingLevel(2)`), and make sure the driver *really* sends a `remove` to your database. Try to perform the operation from the mongo console and look what happens there. That will help to identify whether your mongod or the driver behaves strangely or something else is causing this. One possibility is that you have an item with a duplicate `_id` which can be caused by certain replication bugs, those can't be deleted regularly. – mnemosyn Feb 20 '14 at 10:46

0 Answers0