Differences between revisions 2 and 3
Revision 2 as of 2012-02-07 02:09:29
Size: 1996
Editor: 12
Comment: possible_ancestors
Revision 3 as of 2018-04-13 05:41:27
Size: 0
Editor: JoanTouzet
Comment: migrated
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:

= HTTP POST _revs_diff =

||'''Query args'''||<-2>None||
||'''Request body'''||<-2>JSON object whose keys are document IDs and values arrays of revision IDs||
||'''Response body'''||<-2>JSON object describing which revisions are not in the database||

== Description ==

Given a set of document/revision IDs, returns the subset of those that do ''not'' correspond to revisions stored in the database.

Its primary use is by the replicator, as an important optimization: after receiving a set of new revision IDs from the source database, the replicator sends this set to the destination database's _revs_diff to find out which of them already exist there. It can then avoid fetching and sending already-known document bodies.

Both the request and response bodies are JSON objects whose keys are document IDs; but the values are structured differently:

 * In the ''request'', a value is an array of revision IDs for that document.
 * In the ''response'', a value is an object with a {{{"missing":}}} key, whose value is a list of revision IDs for that document (the ones that are not stored in the database) and optionally a {{{"possible_ancestors"}}} key, whose value is an array of revision IDs that ''are'' known that might be ancestors of the missing revisions.

'''Disclaimer:''' This information was derived from mailing-list posts and experimentation and has not yet been reviewed by someone familiar with the implementation. --JensAlfke, Dec. 2011

== Example ==
POST /_revs_diff HTTP/1.1
Content-Type: application/json

{"03ee06461a12f3c288bb865b22000170": ["1-b2e54331db828310f3c772d6e042ac9c", "2-3a24009a9525bde9e4bfa8a99046b00d"],
 "82e04f650661c9bdb88c57e044000a4b": ["3-bb39f8c740c6ffb8614c7031b46ac162"]}
HTTP/1.1 200 OK
Cache-Control: must-revalidate

{"03ee06461a12f3c288bb865b22000170": {"missing": ["2-3a24009a9525bde9e4bfa8a99046b00d"]}}