couchbasespring-data-couchbasecouchbase-java-api

n1ql couchbase, Check last element in array matches a condition


I need to select the record where number value matching the last element in the numbers array in couch base n1ql query

Check last element in array matches a condition { name: String, data: { dates: Array, numbers: Array } }


Solution

  • You can get the last element in an array using the array index -1 in N1QL. So in your case, you might want to do something like the following:

    select b.* from `bucket` b where b.data.numbers[-1] > 100;