.random()

Returns one or more random entries from the collection.

random(amount)

Parameter

Default

Description

amount

1

Number (optional)

Number of entries to return

Returns

Description

A single random entry, if the provided parameter is equal to 1, or multiple random entries

// Note: Users is a collection.

Users.getAll(); // [{ name: 'John' }, { name: 'Michael' }, { name: 'Peter' }]

Users.random(); // { name: 'Michael' }
Users.random(2); // [{ name: 'John' }, { name: 'Peter' }]

Last updated