Do a count() first and if the number is less than your offset do a findOne?
How can I create a circular query in MongoDB?
Question
What I what is a query with offset and limit of one, that when the offset is bigger than the count it returns the first one.
For example: if I have a collecton with 3 elements and I do a query with offset = 4 I will get the first element. Any idea of how to implement this?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow