D
D
Dream2021-05-30 15:18:50
Python
Dream, 2021-05-30 15:18:50

How to randomize _id from a collection in MongoDB?

Hello, how can random.choices() be used to randomly output one _id from the entire collection in MongoDB?

Example:
There is a collection, it contains: "_id": 1, "_id": 2, "_id": 3
Random must choose one _id from three possible ones, for example, output: "_id": 3

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question