I have only rev id and now I want to retrieve data by rev id in the Couch Db.
Asked
Active
Viewed 366 times
-2
-
Does this answer your question? https://stackoverflow.com/q/54947820/13860 – Jonathan Hall Jul 21 '20 at 10:14
-
I have rev number only and with that number I want to fetch the data. That's all – Krunal Pandya Jul 21 '20 at 10:39
-
How did you end up with a rev id, but no doc id??? – Jonathan Hall Jul 21 '20 at 11:00
1 Answers
2
So you wish to fetch any document that has a specific _rev, regardless of its _id. Leaving aside the obvious "why???" here, there is nothing in the CouchDB API that supports this, as the rev is not intended to be used without a corresponding id.
But if you really want to do this, I guess you could create a view that emits the _rev as the key and then query the view:
function (doc) {
emit(doc._rev, 1);
}
But note: this is a really bad idea.

xpqz
- 3,617
- 10
- 16
-
OK, but i am not that much good in couch db. Can you please provide me the method to create the view ? – Krunal Pandya Jul 21 '20 at 10:46
-
-
I think with rev I can retrieve the data but after that I am not do that and now I have some data with only rev. – Krunal Pandya Jul 21 '20 at 10:49
-
-
1I think you need to read up a bit on how views work, e.g. from https://docs.couchdb.org/en/stable/ddocs/views/intro.html -- but you can enter the map function directly in fauxton (the couchdb dashboard), which is what I did to test out the above. – xpqz Jul 21 '20 at 10:56