How do I delete a document with id = undefined?

I accidentally created a document with id undefined. I can query the document and see it in views but I don’t know how to delete it since the id is undefined. Is it possible to delete all documents returned by a view without needing their ids? Is there another way I can delete this document?


I don’t think there is such a thing as an undefined document ID — the ID is always a string. It might be an empty string, i.e. "" — try using that to delete it.

The attached image is the result of a search of the view. It shows the id as ‘undefined’ and it isn’t a link like normal so I can’t view or edit the document. It also only comes up from the view search, if I go to Documents for that bucket in the console it doesn’t appear at all so I can’t delete it from there. The only way to find it seems to be from the view, so I would need a way in the view to call delete against all the results without needing the document id returned by the view. So is there anyway to do a delete against a query instead of by specifying document id?

@alexegli how did you get that in there? (which SDK did you use and do you have code to reproduce that) I’m not sure that is the right behavior.

I used the couchnode API to connect to couchbase from a Node.js application (github here: I ran bucket.set(id, object, callback) but afterward found out that the var id was undefined. It didn’t throw an error though, it created the document ok even though the id was undefined. I could try running a delete from couchnode with id = undefined to see if it works that way as well, but I wanted to check if there was a safer way to do it from inside the view, since I know the view can find the document.

Hey alexegli,

It looks like the key is simply named ‘undefined’ (string form). You should be able to execute .remove('undefined) on your bucket object in the Node.js SDK to remove it.

Cheers, Brett

Thanks, that worked! Even though the couchbase console couldn’t handle it as a string the Node js SDK was able to remove it when I specified it as the string “undefined”. I’m not sure why the console had issues finding the document if it was just a regular string id but it must have a special case for when id == “undefined”.

Indeed this is a UI server bug. I raised an issue here: