Get Document by a particular key


I am new to Couchbase lite (Android). Can anyone tell me how can i get a document with a particular key’s (not docId) value (say get document with amount = 3423444). i’ve tried query.setKeys on that view without any luck.


If you haven’t read the guide to views yet, this would be a good time :slight_smile:

I assume you’ve created a view whose map function emits the amount property of the document? In that case, using Query.setKeys should work, if you pass an array of just that one value. (Strings and integers are different, so make sure you specify the key as the same type as what you emit in the map function.)

Alternatively, you can set the startKey and endKey both to the key you want to get.