metricq / aiocouch

🛋 An asynchronous client library for CouchDB 2.x and 3.x
https://aiocouch.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
29 stars 10 forks source link

Implement Document.fetch_info() to issue a HEAD request #20

Closed adrienverge closed 4 years ago

adrienverge commented 4 years ago

There are situations when it's useful to send a tiny HTTP HEAD /db/doc request, to retrieve only the document current revision.

I propose to add a method to retrieve this info:

>>> print(await doc.fetch_info())
{"ok": True,
 "id": "SpaghettiWithMeatballs",
 "rev": "1-917fa2381192822767f010b95b45325b"}

The output is similar to what a HTTP PUT /db/doc would return.

Note: the new return_response argument for RemoteServer._request() will be reused in a future commit (for attachments).

bmario commented 4 years ago

In hindsight, I wish the method would be just be called info() like CouchDB.info() :(

adrienverge commented 4 years ago

Mario, I think only my team is using this function for now. I have no problem with renaming it to .info(), which would be an acceptable breaking change for 1.1.0. Do you want me to make a PR? (or maybe you prefer to push it right away?)