I am looking for a way to find the position of the first document (given some kind of criteria like userId="user123"
) for an ordered N1QL query, so something like this:
SELECT ARRAY_POSITION(allPoints, "user123")
LET allPoints = (SELECT userId from stuff WHERE ... ORDER BY points DESC, userId ASC)
However, it doesn't work since the subquery "allPoints" returns an array of objects (each having just one attribute which is 'userId')
Got the solution 2 minutes after posting :)
I was pretty close, it works like this:
SELECT ARRAY_POSITION(allPoints, {"userId":"user123"})
LET allPoints = (SELECT userId from stuff WHERE ... ORDER BY points DESC, userId ASC)