sample

ReQL command: sample

Command syntax

sequence.sample(number) → selection
stream.sample(number) → array
array.sample(number) → array

Description

Select a given number of elements from a sequence with uniform random distribution. Selection is done without replacement.

If the sequence has less than the requested number of elements (i.e., calling sample(10) on a sequence with only five elements), sample will return the entire sequence in a random order.

Example: Select 3 random heroes.

r.table('marvel').sample(3).run(conn, callback)

Get more help

Couldn't find what you were looking for?

© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/javascript/sample/

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部