MongoDB Get sample data


Example

To get random data from certain collection refer to $sample aggregation.

db.emplyees.aggregate({ $sample: { size:1 } })

where size stands for number of items to select.