I have table with many Users (for example 20 000). And I need to get 20 random user objects (with the condition, for example, “country” field == Spain).
How can I do this with backendless?
I have some ideas, but they are not good for my situation:
- I can use counters and when I register new user, I can set "index" = totalCount - 1. And when I need a random objects, I just generate 20 random numbers and get all objects, where index equal to any of these random numbers. But this approach is not good, when I have condition country == Spain (so this approach is almost impossible)
I can get the collection of objects with my condition country == Spain. And from this collection I need to get random 20 objects. In this case, as far as I understand, I need to use offset when I get data from the collection (when I request a new page form the collection), but in this case I will need to perform 20 requests to backendless (with offset = random index and with page length = 1). So it will take too long to wait for responce.