lsilva
lsilva

Reputation: 197

How to order a Cloudant view by date desc

I would like to order a Cloudant view by date in descending order, and I'm new to NoSQL and I have no ideia how.

This is what I have so far:

function(doc){
  if(doc['type'] == 'DOCUMENT' && doc.date){ 
    emit(doc.date);
  }
}

Upvotes: 0

Views: 426

Answers (1)

halfpad
halfpad

Reputation: 390

When doing your query, specify descending=true

curl "https://$ACCOUNT.cloudant.com/$DATABASE/_design/$DDOC/_view/view_name? descending=true" \
 -H "Content-Type: application/json"

https://cloud.ibm.com/docs/services/Cloudant/api?topic=cloudant-using-views#query-arguments-using_views

Upvotes: 0

Related Questions