سؤال

I'd like to know why the rev property of the couchdb.mapping.Document class is read-only attribute. Even id attribute can be set, and I need in my project to create a new Document with rev, which I obtain from CouchDB view. I know that rev is generated in CouchDB, but that's a pity that creators didn't predict such an exception. Moreover, in my humble opinion there should be a get method for the Document class with paramter: ids - it is many identifiers of documents.

@property
def rev(self):
    """The document revision.

    :rtype: basestring
    """
    if hasattr(self._data, 'rev'): # When data is client.Document
        return self._data.rev
    return self._data.get('_rev')
هل كانت مفيدة؟

المحلول

You say "I need in my project to create a new Document with rev", but whether this is possible in this python lib or not, this is not possible in CouchDB itself so allowing you to set this in your lib would have no effect on your actual data.

The _rev in CouchDB is tightly managed by CouchDB for conflict resolution, you cannot change it from the values that CouchDB sets it to. (FWIW, CouchDB allows you to set any (unique) _id you like, which is why that's a writeable field in your python lib).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top