couchdbcloudant

CloudAnt: return only the last document matching an array of keys


Say I have documents in my database with key values "a","b","c", etc.

Now I want to fetch the last matching value of multiple keys, such as keys:["a", "c"], returning the doc for "c" only.

Is there an efficient way to do this in CloudAnt/CouchDB? I'd prefer not to retrieve all matches, just the last. Do I have to use index/selector for this?


Solution

  • I wound up doing a multikey request to an existing view, then reducing the result in the client. I suppose I could do this via a 'reduce' function in the original view, which would lighten the response body.