I'm currently learning MongoDb and creating an app on python
. I need to select one random document from user
collection using uMongo, I have tried aggregate
but it says that umongo have no this function. How can i do that?
Asked
Active
Viewed 116 times
0
-
What did you try? – Itamar Mushkin Mar 04 '20 at 08:36
-
Try: `user.collection.aggregate(...)`. [$sample](https://docs.mongodb.com/manual/reference/operator/aggregation/sample/index.html) returns random document – Valijon Mar 04 '20 at 08:51
1 Answers
0
Indeed, you need to use the aggregation framework.
To do so, you must circumvent umongo to call the underlying driver (e.g. pymongo) directly.

Jérôme
- 13,328
- 7
- 56
- 106