mercredi 28 juillet 2021

How to select random documents from the MongoDB collection but not the previous ones?

I have a collection of videos in MongoDB and want to select random videos documents from that collection the below code is working fine

 const videos = await Video.aggregate([{ $sample: { size: Number(num) } }]);

but it also includes the previous result in the next query. I want to select random videos documents but not the previous ones.




Aucun commentaire:

Enregistrer un commentaire