title: Getting the latest (timestamp wise) value from cloudant query
body: <p>I have a cloudant DB where each document looks like:</p>
  
  <pre><code>{
    "_id": "2015-11-20_attr_00",
    "key": "attr",
    "value": "00",
    "employeeCount": 12,
    "timestamp": "2015-11-20T18:16:05.366Z",
    "epocTimestampMillis": 1448043365366,
    "docType": "attrCounts"
  }
  </code></pre>
  
  <p>For a given attribute there is an employee count. As you can see I have a record for the same attribute every day. I am trying to create a view or index that will give me the latest record for this attribute. Meaning if I inserted a record on 2015-10-30 and another on 2015-11-10, then the one that is returned to me is just employee count for the record with timestamp 2015-11-10.</p>
  
  <p>I have tried view, but I am getting all the entries for each attribute not just the latest. I did not look at indexes because I thought they do not get pre calculated. I will be querying this from client side, so having it pre calculated (like views are) is important.</p>
  
  <p>Any guidance would be most appreciated. thank you</p>