Good day fellow developers,
I hope coding has been as fun for you as it has been for me.
Currently, am facing a challenge of obtaining a list of random Items from MongoDB (10 totally random Items that fit a query).
After perusing the first few pages of Google searches, I decided to rewrite the challenge in greater detail, in hope to pick the brains of StackOverflow's amazing developer community. Am certain that even we will be able to sieve out the best answer for such a challenge.
Hopefully, everyone who faces a similar question can find a answer they desire.
Context:
The best solutions thus far, are catered to only single random retrievals.
Using a random attribute field pegged to the Mongoose model, link here.
Using a 2d geo spatial attribute pegged to the Mongoose model, enter link description here
However:
The issue with these pseudo random retrieval does not cater for a random retrieval of > 1 items.
For example, if we require 10 documents, the retrieval will retrieve the closest values, which inherently will still be similar and thus the term 'pseudo random'.
How can we get a list of 10 documents within 1 single query which retrieves totally random documents, and will there any considerations for the suggested solution
Thank you
Thank you for your time in reading this, and all the best towards us on our endeavours~
Aucun commentaire:
Enregistrer un commentaire