couchdb-net icon indicating copy to clipboard operation
couchdb-net copied to clipboard

Support for revisions in Find, AddOrUpdate

Open dmlarionov opened this issue 3 years ago • 0 comments

Revisions are essential feature for MVCC in CouchDB. Passing a revision to PUT request makes you aware of the conflict (if happen) via response 409 Conflict from CouchDB HTTP API. That's why we need to support passing revisions to AddOrUpdate method.

To avoid breaking changes with my addition and while more request options might be introduced in future, I contributed to DatabaseApiMethodOptions namespace and:

  • added FindOptions + ICouchDatabase<TSource>.FindAsync paired method
  • added AddOrUpdateOptions + ICouchDatabase<TSource>.AddOrUpdateAsync paired method
  • added AddOptions + ICouchDatabase<TSource>.AddAsync paired method

I suppose in the future another contributors whould't extend method parameters, instead add properties to DatabaseApiMethodOptions.*Options objects.

Unit-tests covering new options are added.

I checked and see that for attachements revisions are already supported by CouchAttachment class which is passing DocumentRev to DownloadAttachmentAsync(..) and DownloadAttachmentAsStreamAsync(..).

Added "Revisions" section to README.

dmlarionov avatar Jul 16 '22 12:07 dmlarionov