tags:

views:

101

answers:

3

Hello,

I have a CouchDB database in production. One of the documents has been edited (in Futon by an other developer).
And it's lost it's ID (don't ask me how he did it).

So now the document's id is an empty string, which makes it impossible to edit or delete via Futon.
Is there a way I could hack into CouchDB to delete that document anyway ?

A: 

I haven't tried it but LoveSeat is supposed to be able to open and edit couchedb files...

Glenn Condron
Seeing what they say, it's only an application to edit the views using the json input/output. Moreover there's zero documentation on how to install it.
Damien MATHIEU
+1  A: 

Technically, a document ID is immutable so actually changing the _id field is not directly possible. Perhaps another document was created as a copy of the first?

It is very unlikely that you truly have a document with an empty string as the ID. Maybe it has something not displayed in Futon, such as a zero-width character or something? (You would still see double-quotes that Futon uses to represent strings in the UI.)

Try this: fetch your database's /_all_docs and find that document in the resultant rows. See what its id is and use that to delete it from Futon or over HTTP.

jhs
No. The _id is really empty. The _all_docs returns the following : `{"id":"","key":"","value":{"rev":"1-e486474adc02feb80880ab5b1ce874d1"}}`
Damien MATHIEU
isaacs
+1  A: 

I couldn't delete the document. But the database itself could be deleted.
And I couldn't reproduce the bug in locale. The other developer says he just removed the _id param and saved. I don't know what happened in CouchDB when he did it. But when I do so, it only recreates a new document (as we'd expect it to do).

So I've been using couch_docs to retrieve the datas locally.
As the id is empty, couch_docs doesn't imports it. So you don't even need to delete it manually.

Then I reimport all the records in an other database. I change the references to the database name in my config and everything works fine.
Destroying the database is not a problem even though there's an empty id.

Damien MATHIEU