Returns one or more random entries from the collection.
Parameter
Default
Description
amount
1
Number (optional)
Number of entries to return
Returns
Data | Array<Data>
A single random entry, if the provided parameter is equal to 1, or multiple random entries
// Note: Users is a collection. Users.get(); // [{ name: 'John' }, { name: 'Michael' }, { name: 'Peter' }] Users.random(); // { name: 'Michael' } Users.random(2); // [{ name: 'John' }, { name: 'Peter' }]
Last updated 2 years ago