Couchbase 7 Upgrade Issue: startKey Not Working as Expected in viewQuery

// rating is rating score (decimal)
// lastDocId is user key
let range
let idRange
let skip
if (chunkIndex > 0) {
  const ld = await db.bucketView.get(lastDocId)
  range = { start: ld.value.rating, end: 99999 }
  idRange = { start: lastDocId, end: 'unknownvalue' }
  skip = 1
}
const viewResult = await db.bucketView.viewQuery(
  'rank', 'rank_by_rating',
  { order: cb.ViewOrdering.Ascending, reduce: false, range, idRange, skip }
)
const result = viewResult.rows

I have been using a viewQuery in Couchbase to retrieve a list of users based on ratings, which has worked well for several years since older versions of Couchbase. When there are ties in ratings, I specify a lastDocId to query parts from that point forward. However, after upgrading to Couchbase 7, the startKey is not functioning properly and returns all data from the beginning. What changes are needed to receive data starting from the specified startKey?

I’m not sure about nodejs, but in the rest api, the quotes for the startkey value need to be included in the string. (because it can also be a number which is not quoted).

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.