獲取樣本資料

要從某些集合中獲取隨機資料,請參閱 $sample 聚合。

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

其中 size 代表要選擇的專案數。