CouchDB's versioning is an absolute boon to the application I'm writing, but each of the objects I want to represent in the database has it's own unique identifier (let's call it my_id
), so I don't really need the _id
field.
Is there a way for me to tell CouchDB that I want to make my field the primary hey (not _id
)?
I'm using ruby's couchrest_model, so I know I can do Model.find_by_my_id(params[:my_id])
if I've put view_by :my_id
in my class, but this feels like I'm storing an _id
for no purpose. Should I care?
would it not be possible to, when you create the document, provide your own id instead of the default one couchb assigns? I don't know if ruby's couchrest can do it, but it's available in the CouchDB API
See here: http://wiki.apache.org/couchdb/HTTP_Document_API#PUT
The document ID is passed into the url.