You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Brad King <br...@gmail.com> on 2008/06/12 16:08:59 UTC

_id and _rev

I wanted to get clarity on the _id and _rev fields. As I'm modeling
this out in c#, I want to create a base Document class that I use for
both creating new documents, and updating existing documents. The
question I have is: will it always be OK to include _id and _rev
fields in my POSTs to create new documents, and just set them to null
values. The behavior I see today seems to be that couchdb will ignore
those properties on POST, as I had hoped. Will this always be the case
or is it a bad practice to include those fields?

Otherwise, I need to create separate Document base classes for create
vs. updates. Please tell me if this makes sense:

    // documents have at a minimum the _id and _rev properties
    public abstract class Document : IDocument
    {
        public string _id { get; set; }
        public string _rev { get; set; }
    }

    public class Entity<T> : Document
    {
        public T entityobject;
    }

This way I always store my serialized objects in an entityobject
field, and can use this for all operations.