https://stackoverflow.com/a/46801925
get the total number of the documents with the aggregate query, position cursor on the randrom int with limit 1
Assuming I get the total number of documents to be 10, each of the documents have their unique IDs. How do I choose random documents from there
use startAt(random_number).limit(1) to get random document from the collection
Ok if I understand you clearly, if random_number is 7, document and position 7 will be gotten?
If the random_number is from the random library, why do we limit it to 1? Because I think its already 1
Обсуждают сегодня